aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-10-28 16:15:04 +0200
committerChocobozzz <me@florianbigard.com>2022-10-28 16:34:08 +0200
commit9e5cf66be7ad897e106f283bee73a165c72e74de (patch)
tree16de6f775c412281236b8f99be8e5118e5a6ff71 /client/src/app/core
parent3f9decbd01d25f1b1805e2764dff4beae7d36c19 (diff)
downloadPeerTube-9e5cf66be7ad897e106f283bee73a165c72e74de.tar.gz
PeerTube-9e5cf66be7ad897e106f283bee73a165c72e74de.tar.zst
PeerTube-9e5cf66be7ad897e106f283bee73a165c72e74de.zip
Breaking API: Consistency with role id/label
Diffstat (limited to 'client/src/app/core')
-rw-r--r--client/src/app/core/auth/auth-user.model.ts6
-rw-r--r--client/src/app/core/users/user-local-storage.service.ts11
-rw-r--r--client/src/app/core/users/user.model.ts10
3 files changed, 17 insertions, 10 deletions
diff --git a/client/src/app/core/auth/auth-user.model.ts b/client/src/app/core/auth/auth-user.model.ts
index a12325421..226075265 100644
--- a/client/src/app/core/auth/auth-user.model.ts
+++ b/client/src/app/core/auth/auth-user.model.ts
@@ -43,16 +43,16 @@ export class AuthUser extends User implements ServerMyUserModel {
43 } 43 }
44 44
45 hasRight (right: UserRight) { 45 hasRight (right: UserRight) {
46 return hasUserRight(this.role, right) 46 return hasUserRight(this.role.id, right)
47 } 47 }
48 48
49 canManage (user: ServerUserModel) { 49 canManage (user: ServerUserModel) {
50 const myRole = this.role 50 const myRole = this.role.id
51 51
52 if (myRole === UserRole.ADMINISTRATOR) return true 52 if (myRole === UserRole.ADMINISTRATOR) return true
53 53
54 // I'm a moderator: I can only manage users 54 // I'm a moderator: I can only manage users
55 return user.role === UserRole.USER 55 return user.role.id === UserRole.USER
56 } 56 }
57 57
58 computeCanSeeVideosLink (quotaObservable: Observable<UserVideoQuota>): Observable<boolean> { 58 computeCanSeeVideosLink (quotaObservable: Observable<UserVideoQuota>): Observable<boolean> {
diff --git a/client/src/app/core/users/user-local-storage.service.ts b/client/src/app/core/users/user-local-storage.service.ts
index f1588bdd2..a047efe8e 100644
--- a/client/src/app/core/users/user-local-storage.service.ts
+++ b/client/src/app/core/users/user-local-storage.service.ts
@@ -59,7 +59,10 @@ export class UserLocalStorageService {
59 id: parseInt(this.localStorageService.getItem(UserLocalStorageKeys.ID), 10), 59 id: parseInt(this.localStorageService.getItem(UserLocalStorageKeys.ID), 10),
60 username: this.localStorageService.getItem(UserLocalStorageKeys.USERNAME), 60 username: this.localStorageService.getItem(UserLocalStorageKeys.USERNAME),
61 email: this.localStorageService.getItem(UserLocalStorageKeys.EMAIL), 61 email: this.localStorageService.getItem(UserLocalStorageKeys.EMAIL),
62 role: parseInt(this.localStorageService.getItem(UserLocalStorageKeys.ROLE), 10) as UserRole, 62 role: {
63 id: parseInt(this.localStorageService.getItem(UserLocalStorageKeys.ROLE), 10) as UserRole,
64 label: ''
65 },
63 66
64 ...this.getUserInfo() 67 ...this.getUserInfo()
65 } 68 }
@@ -69,12 +72,14 @@ export class UserLocalStorageService {
69 id: number 72 id: number
70 username: string 73 username: string
71 email: string 74 email: string
72 role: UserRole 75 role: {
76 id: UserRole
77 }
73 }) { 78 }) {
74 this.localStorageService.setItem(UserLocalStorageKeys.ID, user.id.toString()) 79 this.localStorageService.setItem(UserLocalStorageKeys.ID, user.id.toString())
75 this.localStorageService.setItem(UserLocalStorageKeys.USERNAME, user.username) 80 this.localStorageService.setItem(UserLocalStorageKeys.USERNAME, user.username)
76 this.localStorageService.setItem(UserLocalStorageKeys.EMAIL, user.email) 81 this.localStorageService.setItem(UserLocalStorageKeys.EMAIL, user.email)
77 this.localStorageService.setItem(UserLocalStorageKeys.ROLE, user.role.toString()) 82 this.localStorageService.setItem(UserLocalStorageKeys.ROLE, user.role.id.toString())
78 } 83 }
79 84
80 flushLoggedInUser () { 85 flushLoggedInUser () {
diff --git a/client/src/app/core/users/user.model.ts b/client/src/app/core/users/user.model.ts
index 8385a4012..5534bca33 100644
--- a/client/src/app/core/users/user.model.ts
+++ b/client/src/app/core/users/user.model.ts
@@ -34,8 +34,10 @@ export class User implements UserServerModel {
34 videosHistoryEnabled: boolean 34 videosHistoryEnabled: boolean
35 videoLanguages: string[] 35 videoLanguages: string[]
36 36
37 role: UserRole 37 role: {
38 roleLabel: string 38 id: UserRole
39 label: string
40 }
39 41
40 videoQuota: number 42 videoQuota: number
41 videoQuotaDaily: number 43 videoQuotaDaily: number
@@ -123,7 +125,7 @@ export class User implements UserServerModel {
123 } 125 }
124 126
125 hasRight (right: UserRight) { 127 hasRight (right: UserRight) {
126 return hasUserRight(this.role, right) 128 return hasUserRight(this.role.id, right)
127 } 129 }
128 130
129 patch (obj: UserServerModel) { 131 patch (obj: UserServerModel) {
@@ -148,6 +150,6 @@ export class User implements UserServerModel {
148 isAutoBlocked (serverConfig: HTMLServerConfig) { 150 isAutoBlocked (serverConfig: HTMLServerConfig) {
149 if (serverConfig.autoBlacklist.videos.ofUsers.enabled !== true) return false 151 if (serverConfig.autoBlacklist.videos.ofUsers.enabled !== true) return false
150 152
151 return this.role === UserRole.USER && this.adminFlags !== UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST 153 return this.role.id === UserRole.USER && this.adminFlags !== UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST
152 } 154 }
153} 155}