]>
Commit | Line | Data |
---|---|---|
df98563e | 1 | import { User as UserServerModel, UserRole } from '../../../../../shared' |
69f616ab C |
2 | |
3 | export class User implements UserServerModel { | |
df98563e C |
4 | id: number |
5 | username: string | |
6 | email: string | |
7 | role: UserRole | |
8 | displayNSFW: boolean | |
9 | createdAt: Date | |
7da18e44 | 10 | |
df98563e | 11 | constructor (hash: { |
92fb909c C |
12 | id: number, |
13 | username: string, | |
69f616ab | 14 | email: string, |
46757b47 | 15 | role: UserRole, |
92fb909c | 16 | displayNSFW?: boolean, |
df98563e | 17 | createdAt?: Date |
92fb909c | 18 | }) { |
df98563e C |
19 | this.id = hash.id |
20 | this.username = hash.username | |
21 | this.email = hash.email | |
22 | this.role = hash.role | |
23 | this.displayNSFW = hash.displayNSFW | |
44c5275e | 24 | |
feb4bdfd | 25 | if (hash.createdAt) { |
df98563e | 26 | this.createdAt = hash.createdAt |
44c5275e | 27 | } |
7da18e44 C |
28 | } |
29 | ||
df98563e C |
30 | isAdmin () { |
31 | return this.role === 'admin' | |
7da18e44 C |
32 | } |
33 | } |