diff options
author | Chocobozzz <me@florianbigard.com> | 2018-04-19 11:01:34 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-04-19 11:01:34 +0200 |
commit | 0883b3245bf0deb9106c4041e9afbd3521b79280 (patch) | |
tree | fcb73005e0b31a3b763ee5d22d5fc39c2da89907 /client/src/app/core/auth | |
parent | 04ed10b21e8e1339514faae0bb690e4d97c23b0a (diff) | |
download | PeerTube-0883b3245bf0deb9106c4041e9afbd3521b79280.tar.gz PeerTube-0883b3245bf0deb9106c4041e9afbd3521b79280.tar.zst PeerTube-0883b3245bf0deb9106c4041e9afbd3521b79280.zip |
Add ability to choose what policy we have for NSFW videos
There is a global instance setting and a per user setting
Diffstat (limited to 'client/src/app/core/auth')
-rw-r--r-- | client/src/app/core/auth/auth-user.model.ts | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/client/src/app/core/auth/auth-user.model.ts b/client/src/app/core/auth/auth-user.model.ts index 366eea110..60fe57899 100644 --- a/client/src/app/core/auth/auth-user.model.ts +++ b/client/src/app/core/auth/auth-user.model.ts | |||
@@ -3,6 +3,7 @@ import { UserRight } from '../../../../../shared/models/users/user-right.enum' | |||
3 | // Do not use the barrel (dependency loop) | 3 | // Do not use the barrel (dependency loop) |
4 | import { hasUserRight, UserRole } from '../../../../../shared/models/users/user-role' | 4 | import { hasUserRight, UserRole } from '../../../../../shared/models/users/user-role' |
5 | import { User, UserConstructorHash } from '../../shared/users/user.model' | 5 | import { User, UserConstructorHash } from '../../shared/users/user.model' |
6 | import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type' | ||
6 | 7 | ||
7 | export type TokenOptions = { | 8 | export type TokenOptions = { |
8 | accessToken: string | 9 | accessToken: string |
@@ -70,7 +71,7 @@ export class AuthUser extends User { | |||
70 | ROLE: 'role', | 71 | ROLE: 'role', |
71 | EMAIL: 'email', | 72 | EMAIL: 'email', |
72 | USERNAME: 'username', | 73 | USERNAME: 'username', |
73 | DISPLAY_NSFW: 'display_nsfw', | 74 | DEFAULT_NSFW_POLICY: 'nsfw_policy', |
74 | AUTO_PLAY_VIDEO: 'auto_play_video' | 75 | AUTO_PLAY_VIDEO: 'auto_play_video' |
75 | } | 76 | } |
76 | 77 | ||
@@ -85,7 +86,7 @@ export class AuthUser extends User { | |||
85 | username: peertubeLocalStorage.getItem(this.KEYS.USERNAME), | 86 | username: peertubeLocalStorage.getItem(this.KEYS.USERNAME), |
86 | email: peertubeLocalStorage.getItem(this.KEYS.EMAIL), | 87 | email: peertubeLocalStorage.getItem(this.KEYS.EMAIL), |
87 | role: parseInt(peertubeLocalStorage.getItem(this.KEYS.ROLE), 10) as UserRole, | 88 | role: parseInt(peertubeLocalStorage.getItem(this.KEYS.ROLE), 10) as UserRole, |
88 | displayNSFW: peertubeLocalStorage.getItem(this.KEYS.DISPLAY_NSFW) === 'true', | 89 | nsfwPolicy: peertubeLocalStorage.getItem(this.KEYS.DEFAULT_NSFW_POLICY) as NSFWPolicyType, |
89 | autoPlayVideo: peertubeLocalStorage.getItem(this.KEYS.AUTO_PLAY_VIDEO) === 'true' | 90 | autoPlayVideo: peertubeLocalStorage.getItem(this.KEYS.AUTO_PLAY_VIDEO) === 'true' |
90 | }, | 91 | }, |
91 | Tokens.load() | 92 | Tokens.load() |
@@ -99,7 +100,7 @@ export class AuthUser extends User { | |||
99 | peertubeLocalStorage.removeItem(this.KEYS.USERNAME) | 100 | peertubeLocalStorage.removeItem(this.KEYS.USERNAME) |
100 | peertubeLocalStorage.removeItem(this.KEYS.ID) | 101 | peertubeLocalStorage.removeItem(this.KEYS.ID) |
101 | peertubeLocalStorage.removeItem(this.KEYS.ROLE) | 102 | peertubeLocalStorage.removeItem(this.KEYS.ROLE) |
102 | peertubeLocalStorage.removeItem(this.KEYS.DISPLAY_NSFW) | 103 | peertubeLocalStorage.removeItem(this.KEYS.DEFAULT_NSFW_POLICY) |
103 | peertubeLocalStorage.removeItem(this.KEYS.AUTO_PLAY_VIDEO) | 104 | peertubeLocalStorage.removeItem(this.KEYS.AUTO_PLAY_VIDEO) |
104 | peertubeLocalStorage.removeItem(this.KEYS.EMAIL) | 105 | peertubeLocalStorage.removeItem(this.KEYS.EMAIL) |
105 | Tokens.flush() | 106 | Tokens.flush() |
@@ -136,7 +137,7 @@ export class AuthUser extends User { | |||
136 | peertubeLocalStorage.setItem(AuthUser.KEYS.USERNAME, this.username) | 137 | peertubeLocalStorage.setItem(AuthUser.KEYS.USERNAME, this.username) |
137 | peertubeLocalStorage.setItem(AuthUser.KEYS.EMAIL, this.email) | 138 | peertubeLocalStorage.setItem(AuthUser.KEYS.EMAIL, this.email) |
138 | peertubeLocalStorage.setItem(AuthUser.KEYS.ROLE, this.role.toString()) | 139 | peertubeLocalStorage.setItem(AuthUser.KEYS.ROLE, this.role.toString()) |
139 | peertubeLocalStorage.setItem(AuthUser.KEYS.DISPLAY_NSFW, JSON.stringify(this.displayNSFW)) | 140 | peertubeLocalStorage.setItem(AuthUser.KEYS.DEFAULT_NSFW_POLICY, this.nsfwPolicy.toString()) |
140 | peertubeLocalStorage.setItem(AuthUser.KEYS.AUTO_PLAY_VIDEO, JSON.stringify(this.autoPlayVideo)) | 141 | peertubeLocalStorage.setItem(AuthUser.KEYS.AUTO_PLAY_VIDEO, JSON.stringify(this.autoPlayVideo)) |
141 | this.tokens.save() | 142 | this.tokens.save() |
142 | } | 143 | } |