cookie sso
This commit is contained in:
parent
217b30c287
commit
17230bee6b
4 changed files with 15 additions and 6 deletions
|
|
@ -10,8 +10,9 @@ interface AuthResponse {
|
|||
|
||||
const authenticated = async () => ((await getToken()) ? true : false);
|
||||
|
||||
async function setAuthen(r: AuthResponse) {
|
||||
async function setAuthen(r: AuthResponse, val: string) {
|
||||
await setCookie(ACCESS_TOKEN, r.access_token, r.expires_in);
|
||||
setCookie("SSO", val, r.expires_in);
|
||||
window.location.href = "/";
|
||||
}
|
||||
|
||||
|
|
@ -70,4 +71,4 @@ async function tokenParsed() {
|
|||
return JSON.parse(jsonPayload);
|
||||
}
|
||||
|
||||
export { getToken, authenticated, logout, setAuthen, tokenParsed };
|
||||
export { getToken, authenticated, logout, setAuthen, tokenParsed, getCookie };
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { useQuasar } from "quasar";
|
|||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import CustomComponent from "@/components/CustomDialog.vue";
|
||||
import avatar from "@/assets/avatar_user.jpg";
|
||||
import { tokenParsed, logout } from "@/plugins/auth";
|
||||
import { tokenParsed, logout, getCookie } from "@/plugins/auth";
|
||||
|
||||
import { useDataStore } from "@/stores/data";
|
||||
|
||||
|
|
@ -39,6 +39,7 @@ const notiTrigger = ref(false);
|
|||
const currentRouteName = router.currentRoute.value.name;
|
||||
const tab = ref<any>(currentRouteName);
|
||||
const link = ref<string>("");
|
||||
const isSsoToken = ref(false);
|
||||
|
||||
/**
|
||||
* เรียกฟังก์ชันทั้งหมดตอนเรียกใช้ไฟล์นี้
|
||||
|
|
@ -47,6 +48,8 @@ onMounted(async () => {
|
|||
await checkUser();
|
||||
await fetchTotolNotificate();
|
||||
const user = await tokenParsed();
|
||||
const SSO_TOKEN = await getCookie("SSO");
|
||||
isSsoToken.value = SSO_TOKEN === "y" ? true : false;
|
||||
fullname.value = user?.name;
|
||||
});
|
||||
|
||||
|
|
@ -496,7 +499,12 @@ function onViewDetailNoti(url: string) {
|
|||
</q-item>
|
||||
</template>
|
||||
<q-list>
|
||||
<q-item clickable v-close-popup :href="landingPageUrl">
|
||||
<q-item
|
||||
clickable
|
||||
v-close-popup
|
||||
:href="landingPageUrl"
|
||||
v-if="isSsoToken"
|
||||
>
|
||||
<q-item-section avatar style="min-width: 30px">
|
||||
<q-avatar
|
||||
color="blue"
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ onMounted(async () => {
|
|||
expires_in: route.query.expires ? route.query.expires : 36000,
|
||||
refresh_token: route.query.accessToken,
|
||||
};
|
||||
setAuthen(params);
|
||||
setAuthen(params, "y");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ async function onSubmit() {
|
|||
},
|
||||
})
|
||||
.then(async (res) => {
|
||||
setAuthen(res.data.result);
|
||||
setAuthen(res.data.result,'n');
|
||||
})
|
||||
.catch((err) => {
|
||||
$q.dialog({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue