From 4a6995be18b15de1834a39c8921a0e4109671bb6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 3 Jun 2016 22:08:03 +0200 Subject: First draft to use webpack instead of systemjs --- client/src/app/shared/users/token.model.ts | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 client/src/app/shared/users/token.model.ts (limited to 'client/src/app/shared/users/token.model.ts') diff --git a/client/src/app/shared/users/token.model.ts b/client/src/app/shared/users/token.model.ts new file mode 100644 index 000000000..021c83fad --- /dev/null +++ b/client/src/app/shared/users/token.model.ts @@ -0,0 +1,32 @@ +export class Token { + access_token: string; + refresh_token: string; + token_type: string; + + static load() { + return new Token({ + access_token: localStorage.getItem('access_token'), + refresh_token: localStorage.getItem('refresh_token'), + token_type: localStorage.getItem('token_type') + }); + } + + constructor(hash?: any) { + if (hash) { + this.access_token = hash.access_token; + this.refresh_token = hash.refresh_token; + + if (hash.token_type === 'bearer') { + this.token_type = 'Bearer'; + } else { + this.token_type = hash.token_type; + } + } + } + + save() { + localStorage.setItem('access_token', this.access_token); + localStorage.setItem('refresh_token', this.refresh_token); + localStorage.setItem('token_type', this.token_type); + } +} -- cgit v1.2.3