fixing
This commit is contained in:
parent
c82577c05b
commit
28d09e9c5d
1 changed files with 11 additions and 12 deletions
|
|
@ -13,18 +13,17 @@ const keycloak = Keycloak(initOptions);
|
|||
|
||||
keycloak.onAuthSuccess = () => {
|
||||
// check role user
|
||||
const hasCommonValues = (array1: string[], array2: string[]): boolean => {
|
||||
return array1.some((element) => array2.includes(element));
|
||||
};
|
||||
|
||||
const role = keycloak.tokenParsed?.role;
|
||||
const roleSys = ["SUPER_ADMIN", "ADMIN"];
|
||||
const checkPermission = hasCommonValues(role, roleSys);
|
||||
if (!checkPermission) {
|
||||
keycloak.logout({
|
||||
redirectUri: `${window.location.protocol}//${window.location.host}/`,
|
||||
});
|
||||
}
|
||||
// const hasCommonValues = (array1: string[], array2: string[]): boolean => {
|
||||
// return array1.some((element) => array2.includes(element));
|
||||
// };
|
||||
// const role = keycloak.tokenParsed?.role;
|
||||
// const roleSys = ["SUPER_ADMIN", "ADMIN"];
|
||||
// const checkPermission = hasCommonValues(role, roleSys);
|
||||
// if (!checkPermission) {
|
||||
// keycloak.logout({
|
||||
// redirectUri: `${window.location.protocol}//${window.location.host}/`,
|
||||
// });
|
||||
// }
|
||||
}; //เพิ่มlogin สำเร็จจะมาทำฟังก์ชันนี้
|
||||
|
||||
await keycloak.init({ onLoad: "check-sso", checkLoginIframe: false }); //ทำการ connect keycloak
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue