mirror of
https://github.com/kevin-DL/commander_league_web.git
synced 2026-01-15 03:34:48 +00:00
Initial commit from Create Next App
This commit is contained in:
19
utils/auth/userCookies.js
Normal file
19
utils/auth/userCookies.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import cookies from 'js-cookie'
|
||||
|
||||
export const getUserFromCookie = () => {
|
||||
const cookie = cookies.get('auth')
|
||||
if (!cookie) {
|
||||
return
|
||||
}
|
||||
return JSON.parse(cookie)
|
||||
}
|
||||
|
||||
export const setUserCookie = (user) => {
|
||||
cookies.set('auth', user, {
|
||||
// firebase id tokens expire in one hour
|
||||
// set cookie expiry to match
|
||||
expires: 1 / 24,
|
||||
})
|
||||
}
|
||||
|
||||
export const removeUserCookie = () => cookies.remove('auth')
|
||||
Reference in New Issue
Block a user