aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/auth
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-04-04 21:37:03 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-04-04 21:37:03 +0200
commit92fb909c9b4a92a00b0d0da7629e6fb003de281b (patch)
tree8119c6720d5dec0474983501843f1e699fde150a /client/src/app/core/auth
parent1d49e1e27d63db1dfc9a7fd28c9902f488831a89 (diff)
downloadPeerTube-92fb909c9b4a92a00b0d0da7629e6fb003de281b.tar.gz
PeerTube-92fb909c9b4a92a00b0d0da7629e6fb003de281b.tar.zst
PeerTube-92fb909c9b4a92a00b0d0da7629e6fb003de281b.zip
Client: Handle NSFW video
Diffstat (limited to 'client/src/app/core/auth')
-rw-r--r--client/src/app/core/auth/auth-user.model.ts15
1 files changed, 12 insertions, 3 deletions
diff --git a/client/src/app/core/auth/auth-user.model.ts b/client/src/app/core/auth/auth-user.model.ts
index 5d61954d6..cb7e88d19 100644
--- a/client/src/app/core/auth/auth-user.model.ts
+++ b/client/src/app/core/auth/auth-user.model.ts
@@ -5,7 +5,8 @@ export class AuthUser extends User {
5 private static KEYS = { 5 private static KEYS = {
6 ID: 'id', 6 ID: 'id',
7 ROLE: 'role', 7 ROLE: 'role',
8 USERNAME: 'username' 8 USERNAME: 'username',
9 DISPLAY_NSFW: 'display_nsfw'
9 }; 10 };
10 11
11 tokens: Tokens; 12 tokens: Tokens;
@@ -17,7 +18,8 @@ export class AuthUser extends User {
17 { 18 {
18 id: parseInt(localStorage.getItem(this.KEYS.ID)), 19 id: parseInt(localStorage.getItem(this.KEYS.ID)),
19 username: localStorage.getItem(this.KEYS.USERNAME), 20 username: localStorage.getItem(this.KEYS.USERNAME),
20 role: localStorage.getItem(this.KEYS.ROLE) 21 role: localStorage.getItem(this.KEYS.ROLE),
22 displayNSFW: localStorage.getItem(this.KEYS.DISPLAY_NSFW) === 'true'
21 }, 23 },
22 Tokens.load() 24 Tokens.load()
23 ); 25 );
@@ -30,10 +32,16 @@ export class AuthUser extends User {
30 localStorage.removeItem(this.KEYS.USERNAME); 32 localStorage.removeItem(this.KEYS.USERNAME);
31 localStorage.removeItem(this.KEYS.ID); 33 localStorage.removeItem(this.KEYS.ID);
32 localStorage.removeItem(this.KEYS.ROLE); 34 localStorage.removeItem(this.KEYS.ROLE);
35 localStorage.removeItem(this.KEYS.DISPLAY_NSFW);
33 Tokens.flush(); 36 Tokens.flush();
34 } 37 }
35 38
36 constructor(userHash: { id: number, username: string, role: string }, hashTokens: any) { 39 constructor(userHash: {
40 id: number,
41 username: string,
42 role: string,
43 displayNSFW: boolean
44 }, hashTokens: any) {
37 super(userHash); 45 super(userHash);
38 this.tokens = new Tokens(hashTokens); 46 this.tokens = new Tokens(hashTokens);
39 } 47 }
@@ -59,6 +67,7 @@ export class AuthUser extends User {
59 localStorage.setItem(AuthUser.KEYS.ID, this.id.toString()); 67 localStorage.setItem(AuthUser.KEYS.ID, this.id.toString());
60 localStorage.setItem(AuthUser.KEYS.USERNAME, this.username); 68 localStorage.setItem(AuthUser.KEYS.USERNAME, this.username);
61 localStorage.setItem(AuthUser.KEYS.ROLE, this.role); 69 localStorage.setItem(AuthUser.KEYS.ROLE, this.role);
70 localStorage.setItem(AuthUser.KEYS.DISPLAY_NSFW, JSON.stringify(this.displayNSFW);
62 this.tokens.save(); 71 this.tokens.save();
63 } 72 }
64} 73}