-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
51 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import cookies from 'js-cookie'; | ||
|
||
class Cookie { | ||
public static getCookie(key: string): any { | ||
return cookies.get(key); | ||
} | ||
|
||
public static setCookie( | ||
key: string, | ||
value: any, | ||
expires: number | Date = 7 | ||
): void { | ||
cookies.set(key, value, { expires }); | ||
} | ||
|
||
public static removeCookie(key: string): void { | ||
cookies.remove(key); | ||
} | ||
} | ||
|
||
export default Cookie; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './cookie'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { setToken, getToken } from './token'; | ||
export { default } from './token'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
export const setToken = (tokenKey: string, token: string) => { | ||
sessionStorage.setItem(tokenKey, token); | ||
}; | ||
import Cookie from 'lib/cookie'; | ||
|
||
export const getToken = (): string => { | ||
return sessionStorage.getItem('access_token') as string; | ||
}; | ||
class Token { | ||
private static FIRE_DAY = 9 * 60 * 60 * 60 * 1000; | ||
|
||
public static setToken(tokenKey: string, token: string): void { | ||
const date = new Date(); | ||
date.setTime(date.getTime() + this.FIRE_DAY); | ||
Cookie.setCookie(tokenKey, token, date); | ||
} | ||
|
||
public static getToken(tokenKey: string): string { | ||
return Cookie.getCookie(tokenKey) as string; | ||
} | ||
} | ||
|
||
export default Token; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2069,6 +2069,11 @@ | |
jest-diff "^26.0.0" | ||
pretty-format "^26.0.0" | ||
|
||
"@types/js-cookie@^2.2.7": | ||
version "2.2.7" | ||
resolved "https://registry.yarnpkg.com/@types/js-cookie/-/js-cookie-2.2.7.tgz#226a9e31680835a6188e887f3988e60c04d3f6a3" | ||
integrity sha512-aLkWa0C0vO5b4Sr798E26QgOkss68Un0bLjs7u9qxzPT5CG+8DuNTffWES58YzJs3hrVAOs1wonycqEBqNJubA== | ||
|
||
"@types/json-schema@*", "@types/json-schema@^7.0.3", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.6": | ||
version "7.0.7" | ||
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.7.tgz#98a993516c859eb0d5c4c8f098317a9ea68db9ad" | ||
|
@@ -7473,6 +7478,11 @@ [email protected]: | |
import-local "^3.0.2" | ||
jest-cli "^26.6.0" | ||
|
||
js-cookie@^3.0.0: | ||
version "3.0.0" | ||
resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-3.0.0.tgz#db1661d5459920ec95aaf186ccf74ceb4a495164" | ||
integrity sha512-oUbbplKuH07/XX2YD2+Q+GMiPpnVXaRz8npE7suhBH9QEkJe2W7mQ6rwuMXHue3fpfcftQwzgyvGzIHyfCSngQ== | ||
|
||
"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" | ||
|