2018-03-24 16:51:04 +00:00
|
|
|
import LocalStorageInterface from './local-storage-interface'
|
|
|
|
|
2018-03-24 15:49:00 +00:00
|
|
|
export default class Authentication{
|
|
|
|
|
|
|
|
|
|
|
|
/* (1) Constructs an Authentication object
|
|
|
|
*
|
|
|
|
*
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
constructor(){
|
|
|
|
|
2018-03-24 16:51:04 +00:00
|
|
|
/* (1) Default localStorage Interface */
|
|
|
|
this.lsi = new LocalStorageInterface('__auth__', 5*60);
|
|
|
|
|
|
|
|
/* (2) Update token */
|
|
|
|
if( this.token !== null )
|
|
|
|
this.lsi.push('token', this.token);
|
2018-03-24 15:49:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-03-24 16:51:04 +00:00
|
|
|
|
|
|
|
/* (2) TOKEN facade
|
|
|
|
*
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
get token(){ return this.lsi.fetch('token'); }
|
|
|
|
set token(_token){ return this.lsi.push('token', _token); }
|
|
|
|
|
2018-03-24 15:49:00 +00:00
|
|
|
}
|