aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/angular/users/models/user.ts
blob: 2c56a61327a8fd4186b81d290592c38b00e9a661 (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';

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

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

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

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