diff --git a/src/main.ts b/src/main.ts
index 646376a1b..24545e6ac 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -98,24 +98,27 @@ const kcToken = getCookie("BMAHRIS_KEYCLOAK_IDENTITY");
const kcRefreshToken = getCookie("BMAHRIS_KEYCLOAK_REFRESH");
if (kcToken && kcRefreshToken) {
- keycloak
- .init({
- // onLoad: 'login-required',
- checkLoginIframe: false,
- token: kcToken,
- refreshToken: kcRefreshToken,
- })
- .then((authenticated) => {
- console.log("authenticated", authenticated);
- if (!authenticated) {
- window.location.reload();
- } else {
- console.log("Authenticated");
- }
- })
- .catch((err) => {
- console.error("Keycloak initialization failed:", err);
- });
+ keycloak.init({
+ // onLoad: 'login-required',
+ checkLoginIframe: false,
+ token: kcToken,
+ refreshToken: kcRefreshToken,
+ });
+ keycloak.authenticated = true;
+
+ // .then((authenticated) => {
+ // console.log("authenticated", authenticated);
+ // if (!authenticated) {
+ // window.location.reload();
+ // } else {
+ // console.log("Authenticated");
+ // }
+ // })
+ // .catch((err) => {
+ // console.error("Keycloak initialization failed:", err);
+ // });
+} else {
+ keycloak.authenticated = false;
}
app.mount("#app");
diff --git a/src/plugins/http.ts b/src/plugins/http.ts
index 813c81a9c..8aebceb21 100644
--- a/src/plugins/http.ts
+++ b/src/plugins/http.ts
@@ -33,6 +33,8 @@ http.interceptors.response.use(
// eslint-disable-next-line no-prototype-builtins
if (error.hasOwnProperty("response")) {
if (error.response.status === 401 || error.response.status === 403) {
+ window.location.href = "/login";
+
// Store.commit("SET_ERROR_MESSAGE", error.response.data.message);
// Store.commit("REMOVE_ACCESS_TOKEN")
}
diff --git a/src/router/index.ts b/src/router/index.ts
index a3e912901..79747b623 100644
--- a/src/router/index.ts
+++ b/src/router/index.ts
@@ -108,7 +108,7 @@ const router = createRouter({
// authen with keycloak client
router.beforeEach((to, from, next) => {
if (to.meta.Auth) {
- if (keycloak.authenticated === undefined && to.meta.Auth) {
+ if (keycloak.authenticated === false && to.meta.Auth) {
window.location.href = "/login";
}
} else {
diff --git a/src/views/auth.vue b/src/views/auth.vue
new file mode 100644
index 000000000..13301ef08
--- /dev/null
+++ b/src/views/auth.vue
@@ -0,0 +1,30 @@
+
+
+
+
+
diff --git a/src/views/login.vue b/src/views/login.vue
index ea2b1c615..459c7f719 100644
--- a/src/views/login.vue
+++ b/src/views/login.vue
@@ -1,42 +1,42 @@
@@ -184,8 +191,8 @@ async function onSubmit() {
margin-bottom: 10px;
}
-input[type='checkbox'],
-input[type='radio'] {
+input[type="checkbox"],
+input[type="radio"] {
margin: 1px 3px 0 0;
line-height: normal;
}
@@ -218,8 +225,8 @@ input[type='radio'] {
z-index: 1 !important;
}
.bg-image {
- font-family: 'Noto Sans Thai', sans-serif;
- font-family: 'Noto Sans Thai', sans-serif;
+ font-family: "Noto Sans Thai", sans-serif;
+ font-family: "Noto Sans Thai", sans-serif;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;