aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-01-03 15:01:17 +0100
committerChocobozzz <me@florianbigard.com>2020-01-03 15:01:17 +0100
commitb7819090de8ced71e5f9c5773c575ab627a148e4 (patch)
tree1da6089c12e5b60ea2d0868dc5ccecc3d2abfe5d /client/src/app/core
parentac0868bcc0259d4ff14265d9ae403e10869a13aa (diff)
downloadPeerTube-b7819090de8ced71e5f9c5773c575ab627a148e4.tar.gz
PeerTube-b7819090de8ced71e5f9c5773c575ab627a148e4.tar.zst
PeerTube-b7819090de8ced71e5f9c5773c575ab627a148e4.zip
Move watch later logic in miniature
Diffstat (limited to 'client/src/app/core')
-rw-r--r--client/src/app/core/auth/auth-user.model.ts13
1 files changed, 7 insertions, 6 deletions
diff --git a/client/src/app/core/auth/auth-user.model.ts b/client/src/app/core/auth/auth-user.model.ts
index 55a5a6dde..0843743c9 100644
--- a/client/src/app/core/auth/auth-user.model.ts
+++ b/client/src/app/core/auth/auth-user.model.ts
@@ -1,11 +1,10 @@
1import { peertubeLocalStorage } from '@app/shared/misc/peertube-web-storage' 1import { peertubeLocalStorage } from '@app/shared/misc/peertube-web-storage'
2import { UserRight } from '../../../../../shared/models/users/user-right.enum' 2import { UserRight } from '../../../../../shared/models/users/user-right.enum'
3import { User as ServerUserModel } from '../../../../../shared/models/users/user.model' 3import { MyUser as ServerMyUserModel, MyUserSpecialPlaylist } from '../../../../../shared/models/users/user.model'
4// Do not use the barrel (dependency loop) 4// Do not use the barrel (dependency loop)
5import { hasUserRight, UserRole } from '../../../../../shared/models/users/user-role' 5import { hasUserRight, UserRole } from '../../../../../shared/models/users/user-role'
6import { User } from '../../shared/users/user.model' 6import { User } from '../../shared/users/user.model'
7import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type' 7import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type'
8import { VideoPlaylist } from '@app/shared/video-playlist/video-playlist.model'
9 8
10export type TokenOptions = { 9export type TokenOptions = {
11 accessToken: string 10 accessToken: string
@@ -67,7 +66,7 @@ class Tokens {
67 } 66 }
68} 67}
69 68
70export class AuthUser extends User { 69export class AuthUser extends User implements ServerMyUserModel {
71 private static KEYS = { 70 private static KEYS = {
72 ID: 'id', 71 ID: 'id',
73 ROLE: 'role', 72 ROLE: 'role',
@@ -80,7 +79,7 @@ export class AuthUser extends User {
80 } 79 }
81 80
82 tokens: Tokens 81 tokens: Tokens
83 specialPlaylists: Partial<VideoPlaylist>[] 82 specialPlaylists: MyUserSpecialPlaylist[]
84 83
85 static load () { 84 static load () {
86 const usernameLocalStorage = peertubeLocalStorage.getItem(this.KEYS.USERNAME) 85 const usernameLocalStorage = peertubeLocalStorage.getItem(this.KEYS.USERNAME)
@@ -115,9 +114,11 @@ export class AuthUser extends User {
115 Tokens.flush() 114 Tokens.flush()
116 } 115 }
117 116
118 constructor (userHash: Partial<ServerUserModel>, hashTokens: TokenOptions) { 117 constructor (userHash: Partial<ServerMyUserModel>, hashTokens: TokenOptions) {
119 super(userHash) 118 super(userHash)
119
120 this.tokens = new Tokens(hashTokens) 120 this.tokens = new Tokens(hashTokens)
121 this.specialPlaylists = userHash.specialPlaylists
121 } 122 }
122 123
123 getAccessToken () { 124 getAccessToken () {
@@ -141,7 +142,7 @@ export class AuthUser extends User {
141 return hasUserRight(this.role, right) 142 return hasUserRight(this.role, right)
142 } 143 }
143 144
144 canManage (user: ServerUserModel) { 145 canManage (user: ServerMyUserModel) {
145 const myRole = this.role 146 const myRole = this.role
146 147
147 if (myRole === UserRole.ADMINISTRATOR) return true 148 if (myRole === UserRole.ADMINISTRATOR) return true