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
No related branches found
No related tags found
No related merge requests found
......@@ -52,6 +52,8 @@ class SessionManager {
async login(user: string, password: string) {
const spinner: ora.Ora = ora('Logging in').start();
try {
this.profile = new User();
const response = await axios.post(HttpManager.LOGIN_URL, {
user : user,
password: password
......@@ -82,13 +84,13 @@ class SessionManager {
}
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({
text : verboseText,
indent: 8
indent: 4
});
let isAllowed: boolean = permissionPredicate();
let isAllowed: boolean = this.profile.id !== -1 && permissionPredicate();
if ( verbose ) {
spinner.start();
......@@ -96,7 +98,7 @@ class SessionManager {
}
return isAllowed;
}
};
return {
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