Skip to content
Snippets Groups Projects
Commit 3b688ca5 authored by michael.minelli's avatar michael.minelli
Browse files

Session => bug fix: stop to show false informations about permissions

parent e07f8a42
Branches
No related tags found
No related merge requests found
...@@ -52,6 +52,8 @@ class SessionManager { ...@@ -52,6 +52,8 @@ class SessionManager {
async login(user: string, password: string) { async login(user: string, password: string) {
const spinner: ora.Ora = ora('Logging in').start(); const spinner: ora.Ora = ora('Logging in').start();
try { try {
this.profile = new User();
const response = await axios.post(HttpManager.LOGIN_URL, { const response = await axios.post(HttpManager.LOGIN_URL, {
user : user, user : user,
password: password password: password
...@@ -82,13 +84,13 @@ class SessionManager { ...@@ -82,13 +84,13 @@ class SessionManager {
} }
checkPermissions(verbose: boolean = true, ...checkPermissions: Array<string>): Permissions { checkPermissions(verbose: boolean = true, ...checkPermissions: Array<string>): Permissions {
function hasPermission(permissionPredicate: () => boolean, verboseText: string): boolean { const hasPermission = (permissionPredicate: () => boolean, verboseText: string): boolean => {
const spinner: ora.Ora = ora({ const spinner: ora.Ora = ora({
text : verboseText, text : verboseText,
indent: 8 indent: 4
}); });
let isAllowed: boolean = permissionPredicate(); let isAllowed: boolean = this.profile.id !== -1 && permissionPredicate();
if ( verbose ) { if ( verbose ) {
spinner.start(); spinner.start();
...@@ -96,7 +98,7 @@ class SessionManager { ...@@ -96,7 +98,7 @@ class SessionManager {
} }
return isAllowed; return isAllowed;
} };
return { return {
teachingStaff: checkPermissions.length == 0 || checkPermissions.includes('teachingStaff') ? hasPermission(() => this.profile.isTeachingStaff, 'Teaching staff permissions') : false, teachingStaff: checkPermissions.length == 0 || checkPermissions.includes('teachingStaff') ? hasPermission(() => this.profile.isTeachingStaff, 'Teaching staff permissions') : false,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment