forked from gcc-x-csd/GCCxCSD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CookieHelper.js
40 lines (29 loc) · 1017 Bytes
/
CookieHelper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import Cookies from 'js-cookie';
import jwtDecode from 'jwt-decode';
export function getCookie(name) {
return Cookies.get(name);
}
export function getUID(name) {
const cookieValue = Cookies.get(name)
let user = cookieValue ? JSON.parse(JSON.stringify(jwtDecode(cookieValue))) : undefined
const u = new Object(user)
return u.userID;
}
export function getName(name) {
const cookieValue = Cookies.get(name)
let user = cookieValue ? JSON.parse(JSON.stringify(jwtDecode(cookieValue))) : undefined
const u = new Object(user)
return u.userName;
}
export function getEmail(name) {
const cookieValue = Cookies.get(name)
let user = cookieValue ? JSON.parse(JSON.stringify(jwtDecode(cookieValue))) : undefined
const u = new Object(user)
return u.userEmail;
}
export function getSex(name) {
const cookieValue = Cookies.get(name)
let user = cookieValue ? JSON.parse(JSON.stringify(jwtDecode(cookieValue))) : undefined
const u = new Object(user)
return u.userSex;
}