Merge branch 'feature/vuejs' into feature/vue-serverview

This commit is contained in:
Dane Everitt 2018-07-15 16:50:11 -07:00
commit f2d2725ca0
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
130 changed files with 2275 additions and 1363 deletions

View file

@ -1,39 +1,4 @@
import isString from 'lodash/isString';
import jwtDecode from 'jwt-decode';
export default class User {
/**
* Get a new user model from the JWT.
*
* @return {User | null}
*/
static fromToken(token) {
if (!isString(token)) {
token = localStorage.getItem('token');
}
if (!isString(token) || token.length < 1) {
return null;
}
const data = jwtDecode(token);
if (data.user) {
return new User(data.user);
}
return null;
}
/**
* Return the JWT for the authenticated user.
*
* @returns {string | null}
*/
static getToken()
{
return localStorage.getItem('token');
}
/**
* Create a new user model.
*
@ -45,14 +10,14 @@ export default class User {
* @param {String} language
*/
constructor({
admin,
root_admin,
username,
email,
first_name,
last_name,
language,
}) {
this.admin = admin;
this.admin = root_admin;
this.username = username;
this.email = email;
this.name = `${first_name} ${last_name}`;