]>
Commit | Line | Data |
---|---|---|
b1794c53 C |
1 | export class Token { |
2 | access_token: string; | |
3 | refresh_token: string; | |
4 | token_type: string; | |
5 | ||
ccf6ed16 | 6 | static load() { |
881a5e68 C |
7 | return new Token({ |
8 | access_token: localStorage.getItem('access_token'), | |
9 | refresh_token: localStorage.getItem('refresh_token'), | |
10 | token_type: localStorage.getItem('token_type') | |
11 | }); | |
12 | } | |
13 | ||
ccf6ed16 | 14 | constructor(hash?: any) { |
1553e15d C |
15 | if (hash) { |
16 | this.access_token = hash.access_token; | |
17 | this.refresh_token = hash.refresh_token; | |
ccf6ed16 | 18 | |
1553e15d C |
19 | if (hash.token_type === 'bearer') { |
20 | this.token_type = 'Bearer'; | |
21 | } else { | |
22 | this.token_type = hash.token_type; | |
23 | } | |
24 | } | |
b1794c53 C |
25 | } |
26 | ||
ccf6ed16 | 27 | save() { |
b1794c53 C |
28 | localStorage.setItem('access_token', this.access_token); |
29 | localStorage.setItem('refresh_token', this.refresh_token); | |
30 | localStorage.setItem('token_type', this.token_type); | |
31 | } | |
32 | } |