updated checkin login

This commit is contained in:
Warunee Tamkoo 2025-02-19 18:01:53 +07:00
parent 37372666a4
commit 2e8750a3f8
2 changed files with 13 additions and 7 deletions

View file

@ -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,
}

View file

@ -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',
},