aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/angular/users/models/token.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-04-14 22:07:46 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-04-14 22:07:46 +0200
commit1553e15d82b8a1ec4967a90d43b33274f8215c44 (patch)
treeee53fdbb32895153a1fd2470e1c51cf1d9a38e77 /client/angular/users/models/token.ts
parent0c1cbbfe29d91c95f9c574b57adf067654b8b5b4 (diff)
downloadPeerTube-1553e15d82b8a1ec4967a90d43b33274f8215c44.tar.gz
PeerTube-1553e15d82b8a1ec4967a90d43b33274f8215c44.tar.zst
PeerTube-1553e15d82b8a1ec4967a90d43b33274f8215c44.zip
Implement user requests autorizations in the client side
Diffstat (limited to 'client/angular/users/models/token.ts')
-rw-r--r--client/angular/users/models/token.ts24
1 files changed, 19 insertions, 5 deletions
diff --git a/client/angular/users/models/token.ts b/client/angular/users/models/token.ts
index 688dfdc80..906bf501b 100644
--- a/client/angular/users/models/token.ts
+++ b/client/angular/users/models/token.ts
@@ -3,13 +3,27 @@ export class Token {
3 refresh_token: string; 3 refresh_token: string;
4 token_type: string; 4 token_type: string;
5 5
6 constructor (hash) { 6 constructor (hash?: any) {
7 this.access_token = hash.access_token; 7 if (hash) {
8 this.refresh_token = hash.refresh_token; 8 this.access_token = hash.access_token;
9 this.token_type = hash.token_type; 9 this.refresh_token = hash.refresh_token;
10 if (hash.token_type === 'bearer') {
11 this.token_type = 'Bearer';
12 } else {
13 this.token_type = hash.token_type;
14 }
15 }
10 } 16 }
11 17
12 save() { 18 static load(): Token {
19 return new Token({
20 access_token: localStorage.getItem('access_token'),
21 refresh_token: localStorage.getItem('refresh_token'),
22 token_type: localStorage.getItem('token_type')
23 });
24 }
25
26 save():void {
13 localStorage.setItem('access_token', this.access_token); 27 localStorage.setItem('access_token', this.access_token);
14 localStorage.setItem('refresh_token', this.refresh_token); 28 localStorage.setItem('refresh_token', this.refresh_token);
15 localStorage.setItem('token_type', this.token_type); 29 localStorage.setItem('token_type', this.token_type);