login
This commit is contained in:
parent
c97bbc7a78
commit
7b3a4c18ba
9 changed files with 406 additions and 47 deletions
41
src/main.ts
41
src/main.ts
|
|
@ -3,9 +3,10 @@ import App from "./App.vue";
|
|||
import router from "./router";
|
||||
import { Dialog, Notify, Quasar, Loading } from "quasar";
|
||||
import "./quasar-user-options";
|
||||
import keycloak from "@/plugins/keycloak";
|
||||
|
||||
import qDraggableTable from 'quasar-ui-q-draggable-table';
|
||||
import 'quasar-ui-q-draggable-table/dist/index.css';
|
||||
import qDraggableTable from "quasar-ui-q-draggable-table";
|
||||
import "quasar-ui-q-draggable-table/dist/index.css";
|
||||
|
||||
import "quasar/src/css/index.sass";
|
||||
import th from "quasar/lang/th";
|
||||
|
|
@ -81,4 +82,40 @@ app.component(
|
|||
|
||||
app.config.globalProperties.$http = http;
|
||||
|
||||
// authen with keycloak client
|
||||
function getCookie(name: string) {
|
||||
const nameEQ = name + "=";
|
||||
const ca = document.cookie.split(";");
|
||||
for (let i = 0; i < ca.length; i++) {
|
||||
let c = ca[i];
|
||||
while (c.charAt(0) == " ") c = c.substring(1, c.length);
|
||||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
app.mount("#app");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue