From 2e8750a3f85d2f8938d9bb72d269e9351d989c2b Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Wed, 19 Feb 2025 18:01:53 +0700 Subject: [PATCH] updated checkin login --- src/plugins/auth.ts | 18 ++++++++++++------ src/views/login.vue | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/plugins/auth.ts b/src/plugins/auth.ts index 9928fab..5e8aed4 100644 --- a/src/plugins/auth.ts +++ b/src/plugins/auth.ts @@ -42,13 +42,12 @@ function setCookie(name: string, value: any, time: number) { document.cookie = name + '=' + (value || '') + expires + '; path=/' } -function setCookieCheckin(name: string, value: any, time: number) { +function setCookieCheckin(name: string, value: any, timeInSeconds: number) { let expires = '' - if (time) { + if (timeInSeconds) { const date = new Date() - - // date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000); - date.setMonth(date.getMonth() + 6) + // แปลงวินาทีเป็นมิลลิวินาที (คูณด้วย 1000) + date.setTime(date.getTime() + timeInSeconds * 1000) expires = '; expires=' + date.toUTCString() } document.cookie = name + '=' + (value || '') + expires + '; path=/' @@ -89,4 +88,11 @@ async function tokenParsed() { return JSON.parse(jsonPayload) } -export { getToken, authenticated, logout, setAuthen, tokenParsed ,setAuthenCheckin} +export { + getToken, + authenticated, + logout, + setAuthen, + tokenParsed, + setAuthenCheckin, +} diff --git a/src/views/login.vue b/src/views/login.vue index 80293ff..633ff15 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -24,7 +24,7 @@ async function onSubmit() { formdata.append('password', password.value) await axios - .post(`${env.API_URI}/org/login`, formdata, { + .post(`${env.API_URI}/org/login/checkin`, formdata, { headers: { 'Content-Type': 'application/x-www-form-urlencoded', },