Skip to content

Commit

Permalink
fix: cannot login with oidc
Browse files Browse the repository at this point in the history
  • Loading branch information
ChingCdesu committed Sep 30, 2023
1 parent 334acfe commit 48bcbf2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
23 changes: 17 additions & 6 deletions src/components/login/LoginCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,31 @@ function oidcLogin() {

<template>
<div class="container">
<NCard class="login-card" :bordered="false" :title="$t('message.common.welcomeback')">
<NCard
class="login-card"
:bordered="false"
:title="$t('message.common.welcomeback')"
>
<NSpace vertical>
<div class="input-row">
<Icon size="24">
<UserCircle />
</Icon>
<NInput :placeholder="$t('message.common.username')" v-model:value="inputUsername" />
<NInput
:placeholder="$t('message.common.username')"
v-model:value="inputUsername"
/>
</div>
<div class="input-row">
<Icon size="24">
<Lock />
</Icon>
<NInput type="password" show-password-on="click"
:placeholder="$t('message.common.passcode')" v-model:value="inputPassword" />
<NInput
type="password"
show-password-on="click"
:placeholder="$t('message.common.passcode')"
v-model:value="inputPassword"
/>
</div>
</NSpace>

Expand Down Expand Up @@ -93,7 +104,7 @@ function oidcLogin() {
align-items: center;
text-align: start;
&> :deep(.xicon) {
& > :deep(.xicon) {
margin-right: 4px;
}
}
Expand All @@ -102,7 +113,7 @@ function oidcLogin() {
display: flex;
flex-direction: column;
&>* {
& > * {
margin-bottom: 1em;
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useAuthState } from "@/store/auth";

import HomeRoute from "@/router/routes/home";
import LoginRoute from "@/router/routes/login";
import { getMe } from "@/api/v1/business/users";

const { isExpired } = useAuthState();

Expand All @@ -12,15 +13,19 @@ const router = createRouter({
routes: [HomeRoute, LoginRoute],
});

router.beforeEach((to, from) => {
router.beforeEach((to, from, next) => {
if (to.path.startsWith("/api")) {
return;
}
if (to.path === "/login") {
return;
}
if (!isExpired.value) {
if (isExpired.value) {
return { path: "/login" };
} else {
getMe().catch(() => {
next({ path: "/login" });
});
}
});

Expand Down

0 comments on commit 48bcbf2

Please sign in to comment.