use the new session management
This commit is contained in:
@@ -1,18 +1,12 @@
|
||||
import axios from 'axios';
|
||||
import { Configuration } from './configuration';
|
||||
import { Session } from './session';
|
||||
import { User } from '../types';
|
||||
|
||||
export class Auth {
|
||||
static async user(): Promise<User> {
|
||||
const token = sessionStorage.getItem('token');
|
||||
if (!token) {
|
||||
return {
|
||||
vatsimId: '',
|
||||
fullName: '',
|
||||
administrator: false,
|
||||
airportConfigurationAccess: [],
|
||||
};
|
||||
}
|
||||
static async user(): Promise<User | undefined> {
|
||||
const token = Session.bearerToken();
|
||||
if (!token) return undefined;
|
||||
|
||||
return axios
|
||||
.get<User>(`${Configuration.resourceServer}/auth/user`, {
|
||||
@@ -21,11 +15,6 @@ export class Auth {
|
||||
},
|
||||
})
|
||||
.then((response) => response.data)
|
||||
.catch(() => ({
|
||||
vatsimId: '',
|
||||
fullName: '',
|
||||
administrator: false,
|
||||
airportConfigurationAccess: [],
|
||||
}));
|
||||
.catch(() => undefined);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user