feat:resetPassword
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
parent
c372757351
commit
3a0d655ab0
2 changed files with 45 additions and 6 deletions
|
|
@ -16,4 +16,6 @@ export default {
|
||||||
|
|
||||||
/** กำหนดสิทธิ์*/
|
/** กำหนดสิทธิ์*/
|
||||||
managementPermission,
|
managementPermission,
|
||||||
|
|
||||||
|
resetPassword: `${management}/user/reset-password`,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,11 @@ const {
|
||||||
hideLoader,
|
hideLoader,
|
||||||
success,
|
success,
|
||||||
dialogConfirm,
|
dialogConfirm,
|
||||||
|
dialogMessageNotify,
|
||||||
} = useCounterMixin();
|
} = useCounterMixin();
|
||||||
|
|
||||||
|
const NODE_ENV = ref<string>(process.env.NODE_ENV || "development");
|
||||||
|
|
||||||
/** Tree*/
|
/** Tree*/
|
||||||
const activeId = ref<string>(""); // id ของโครงสร้างที่ใช้งานอยู่
|
const activeId = ref<string>(""); // id ของโครงสร้างที่ใช้งานอยู่
|
||||||
const orgId = ref<string | null>(null); // id ของ node ที่เลือก
|
const orgId = ref<string | null>(null); // id ของ node ที่เลือก
|
||||||
|
|
@ -195,6 +198,12 @@ const itemMenu = ref<ItemsMenu[]>([
|
||||||
color: "blue-9",
|
color: "blue-9",
|
||||||
type: "managementRole",
|
type: "managementRole",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "รีเซ็ตรหัสผ่าน",
|
||||||
|
icon: "mdi-lock-reset",
|
||||||
|
color: "teal-4",
|
||||||
|
type: "resetPassword",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: "ลบ",
|
label: "ลบ",
|
||||||
icon: "delete",
|
icon: "delete",
|
||||||
|
|
@ -281,7 +290,7 @@ async function fetchListUsers() {
|
||||||
e.name === "STAFF" ||
|
e.name === "STAFF" ||
|
||||||
e.name === "SUPER_ADMIN" ||
|
e.name === "SUPER_ADMIN" ||
|
||||||
e.name === "ADMIN" ||
|
e.name === "ADMIN" ||
|
||||||
e.name === "USER"
|
e.name === "USER",
|
||||||
)
|
)
|
||||||
: [],
|
: [],
|
||||||
}));
|
}));
|
||||||
|
|
@ -319,6 +328,8 @@ function onClickAction(type: string, data: Users) {
|
||||||
// เปลี่ยนสถานะเปิด/ปิดของผู้ใช้งาน
|
// เปลี่ยนสถานะเปิด/ปิดของผู้ใช้งาน
|
||||||
const status = type === "open" ? true : false;
|
const status = type === "open" ? true : false;
|
||||||
onLockUser(data.id, status);
|
onLockUser(data.id, status);
|
||||||
|
} else if (type === "resetPassword") {
|
||||||
|
onReSetPassword(data.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -346,7 +357,7 @@ async function onDeleteUser(id: string) {
|
||||||
currentPage.value = await updateCurrentPage(
|
currentPage.value = await updateCurrentPage(
|
||||||
currentPage.value,
|
currentPage.value,
|
||||||
maxPage.value,
|
maxPage.value,
|
||||||
rows.value.length
|
rows.value.length,
|
||||||
);
|
);
|
||||||
await fetchListUsers();
|
await fetchListUsers();
|
||||||
success($q, "ลบข้อมูลสำเร็จ");
|
success($q, "ลบข้อมูลสำเร็จ");
|
||||||
|
|
@ -385,7 +396,7 @@ function onLockUser(id: string, type: boolean) {
|
||||||
type ? "ยืนยันการเปิดใช้" : "ยืนยันการระงับใช้งาน",
|
type ? "ยืนยันการเปิดใช้" : "ยืนยันการระงับใช้งาน",
|
||||||
type
|
type
|
||||||
? "ต้องการยืนยันการเปิดใช้นี้หรือไม่ ?"
|
? "ต้องการยืนยันการเปิดใช้นี้หรือไม่ ?"
|
||||||
: "ต้องการยืนยันระงับการใช้งานนี้หรือไม่ ?"
|
: "ต้องการยืนยันระงับการใช้งานนี้หรือไม่ ?",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -410,7 +421,7 @@ function filterFnOptions(val: string, update: Function, type: string) {
|
||||||
case "employeeClass":
|
case "employeeClass":
|
||||||
update(() => {
|
update(() => {
|
||||||
employeeClassOption.value = employeeClassMain.value.filter(
|
employeeClassOption.value = employeeClassMain.value.filter(
|
||||||
(v: DataOption) => v.name.indexOf(val) > -1
|
(v: DataOption) => v.name.indexOf(val) > -1,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
@ -430,6 +441,32 @@ async function onSearchData() {
|
||||||
await fetchListUsers();
|
await fetchListUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onReSetPassword(id: string) {
|
||||||
|
dialogConfirm(
|
||||||
|
$q,
|
||||||
|
async () => {
|
||||||
|
try {
|
||||||
|
showLoader();
|
||||||
|
const messsage =
|
||||||
|
NODE_ENV.value === "production"
|
||||||
|
? "รหัสผ่านจะถูกเปลี่ยนเป็น วันเดือนปีพุทธศักราชเกิด ของผู้ใช้งาน (รูปแบบ ววดดปปปป เช่น 14042533)"
|
||||||
|
: "ระบบจะตั้งรหัสผ่านใหม่เป็น P@ssw0rd";
|
||||||
|
await http.post(config.API.resetPassword, {
|
||||||
|
keycloak: id,
|
||||||
|
});
|
||||||
|
success($q, "รีเซ็ตรหัสผ่านสำเร็จ");
|
||||||
|
dialogMessageNotify($q, messsage);
|
||||||
|
} catch (error) {
|
||||||
|
messageError($q, error);
|
||||||
|
} finally {
|
||||||
|
hideLoader();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ยืนยันการรีเซ็ตรหัสผ่าน",
|
||||||
|
"ต้องการยืนยันการรีเซ็ตรหัสผ่านนี้หรือไม่ ?",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ดูการเปลี่ยนแปลงของจำนวนข้อมูลต่อหน้า
|
* ดูการเปลี่ยนแปลงของจำนวนข้อมูลต่อหน้า
|
||||||
* ดึงข้อมูลรายชื่อผู้ใช้งานตามจำนวนข้อมูลต่อหน้า
|
* ดึงข้อมูลรายชื่อผู้ใช้งานตามจำนวนข้อมูลต่อหน้า
|
||||||
|
|
@ -438,7 +475,7 @@ watch(
|
||||||
() => pageSize.value,
|
() => pageSize.value,
|
||||||
() => {
|
() => {
|
||||||
fetchListUsers();
|
fetchListUsers();
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const tokenParsedData = ref<string[]>([]);
|
const tokenParsedData = ref<string[]>([]);
|
||||||
|
|
@ -473,7 +510,7 @@ onMounted(async () => {
|
||||||
<template>
|
<template>
|
||||||
<div class="row items-center">
|
<div class="row items-center">
|
||||||
<div class="toptitle text-dark row items-center q-py-xs">
|
<div class="toptitle text-dark row items-center q-py-xs">
|
||||||
จัดการผู้ใช้งาน
|
จัดการผู้ใช้งาน {{ NODE_ENV }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue