]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/users/user.model.ts
Client: Handle NSFW video
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / users / user.model.ts
index ca0a5f26ca01213471b2ec263c6cbbc0fe6dc3f2..f7859f495929ae257c767c76b6f5b0953580b1ad 100644 (file)
@@ -1,20 +1,28 @@
-import { Token } from './token.model';
-
 export class User {
+  id: number;
   username: string;
-  token: Token;
+  role: string;
+  displayNSFW: boolean;
+  createdAt: Date;
 
-  static load() {
-    return new User(localStorage.getItem('username'), Token.load());
-  }
+  constructor(hash: {
+    id: number,
+    username: string,
+    role: string,
+    displayNSFW?: boolean,
+    createdAt?: Date,
+  }) {
+    this.id = hash.id;
+    this.username = hash.username;
+    this.role = hash.role;
+    this.displayNSFW = hash.displayNSFW;
 
-  constructor(username: string, hash_token: any) {
-    this.username = username;
-    this.token = new Token(hash_token);
+    if (hash.createdAt) {
+      this.createdAt = hash.createdAt;
+    }
   }
 
-  save() {
-    localStorage.setItem('username', this.username);
-    this.token.save();
+  isAdmin() {
+    return this.role === 'admin';
   }
 }