]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/users/user.model.ts
Server: Add NSFW in user profile
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / users / user.model.ts
index ca0a5f26ca01213471b2ec263c6cbbc0fe6dc3f2..52d89e0049f53991d6686fcc99d68fe3537ab802 100644 (file)
@@ -1,20 +1,20 @@
-import { Token } from './token.model';
-
 export class User {
+  id: number;
   username: string;
-  token: Token;
+  role: string;
+  createdAt: Date;
 
-  static load() {
-    return new User(localStorage.getItem('username'), Token.load());
-  }
+  constructor(hash: { id: number, username: string, role: string, createdAt?: Date }) {
+    this.id = hash.id;
+    this.username = hash.username;
+    this.role = hash.role;
 
-  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';
   }
 }