aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/app/users/shared/user.model.ts
blob: 73fd4ddc05fb515d7db53270b92e1da17e006a0c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { Token } from './token.model';

export class User {
  username: string;
  token: Token;

  static load(): User {
    return new User(localStorage.getItem('username'), Token.load());
  }

  constructor (username: string, hash_token: any) {
    this.username = username;
    this.token = new Token(hash_token);
  }

  save(): void {
    localStorage.setItem('username', this.username);
    this.token.save();
  }
}