user admin login issues, mostly solved
This commit is contained in:
parent
16fea232e7
commit
4d2dd18484
@ -1,7 +1,7 @@
|
||||
import { Component, ElementRef, ViewChild } from '@angular/core';
|
||||
import { PermissionsService } from '../../../../services/permissions.service';
|
||||
import { AceEditorComponent } from 'ng2-ace-editor';
|
||||
import { RulesControllerService, RuleSetModel } from '@redaction/red-ui-http';
|
||||
import { RulesControllerService } from '@redaction/red-ui-http';
|
||||
import { NotificationService, NotificationType } from '../../../../services/notification.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { saveAs } from 'file-saver';
|
||||
@ -89,7 +89,10 @@ export class RulesScreenComponent extends ComponentHasChanges {
|
||||
public async save(): Promise<void> {
|
||||
this.processing = true;
|
||||
this._rulesControllerService
|
||||
.uploadRules({ rules: this.editorComponent.getEditor().getValue(), ruleSetId: this._appStateService.activeRuleSetId })
|
||||
.uploadRules({
|
||||
rules: this.editorComponent.getEditor().getValue(),
|
||||
ruleSetId: this._appStateService.activeRuleSetId
|
||||
})
|
||||
.subscribe(
|
||||
() => {
|
||||
this._initialize();
|
||||
|
||||
@ -19,6 +19,14 @@ export class RedRoleGuard implements CanActivate {
|
||||
obs.complete();
|
||||
} else {
|
||||
// we have at least 1 RED Role -> if it's not user he must be admin
|
||||
|
||||
if (this._userService.user.isUserAdmin && !this._userService.user.isAdmin && !state.url.startsWith('/main/admin/users')) {
|
||||
this._router.navigate(['/main/admin/users']);
|
||||
obs.next(false);
|
||||
obs.complete();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._userService.isUser() && state.url.startsWith('/main/projects')) {
|
||||
this._router.navigate(['/main/admin']);
|
||||
obs.next(false);
|
||||
|
||||
@ -31,6 +31,10 @@ export class UserWrapper {
|
||||
return this.roles.indexOf('RED_MANAGER') >= 0;
|
||||
}
|
||||
|
||||
get isUserAdmin() {
|
||||
return this.roles.indexOf('RED_USER_ADMIN') >= 0;
|
||||
}
|
||||
|
||||
get isUser() {
|
||||
return this.roles.indexOf('RED_USER') >= 0;
|
||||
}
|
||||
@ -39,12 +43,8 @@ export class UserWrapper {
|
||||
return this.roles.indexOf('RED_ADMIN') >= 0;
|
||||
}
|
||||
|
||||
get isUserAdmin() {
|
||||
return this.roles.indexOf('RED_USER_ADMIN') >= 0;
|
||||
}
|
||||
|
||||
get hasAnyREDRoles() {
|
||||
return this.isUser || this.isManager || this.isAdmin;
|
||||
return this.isUser || this.isManager || this.isAdmin || this.isUserAdmin;
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,7 +153,12 @@ export class UserService {
|
||||
}
|
||||
|
||||
private _hasAnyRedRole(u: User) {
|
||||
return u.roles.indexOf('RED_USER') >= 0 || u.roles.indexOf('RED_MANAGER') >= 0 || u.roles.indexOf('RED_ADMIN') >= 0;
|
||||
return (
|
||||
u.roles.indexOf('RED_USER') >= 0 ||
|
||||
u.roles.indexOf('RED_MANAGER') >= 0 ||
|
||||
u.roles.indexOf('RED_ADMIN') >= 0 ||
|
||||
u.roles.indexOf('RED_USER_ADMIN') >= 0
|
||||
);
|
||||
}
|
||||
|
||||
hasAnyRole(requiredRoles: string[], user?: User) {
|
||||
|
||||
@ -10,10 +10,16 @@ export class AppStateGuard implements CanActivate {
|
||||
constructor(private readonly _appStateService: AppStateService, private readonly _userService: UserService, private readonly _router: Router) {}
|
||||
|
||||
async canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
|
||||
await this._userService.loadAllUsersIfNecessary();
|
||||
await this._appStateService.loadRuleSetsIfNecessary();
|
||||
await this._appStateService.loadDictionaryDataIfNecessary();
|
||||
await this._appStateService.updateDictionaryVersion();
|
||||
if (this._userService.user.isUserAdmin) {
|
||||
await this._userService.loadAllUsersIfNecessary();
|
||||
}
|
||||
|
||||
if (this._userService.user.isUser || this._userService.user.isAdmin) {
|
||||
await this._userService.loadAllUsersIfNecessary();
|
||||
await this._appStateService.loadRuleSetsIfNecessary();
|
||||
await this._appStateService.loadDictionaryDataIfNecessary();
|
||||
await this._appStateService.updateDictionaryVersion();
|
||||
}
|
||||
|
||||
if (this._userService.isUser()) {
|
||||
await this._appStateService.loadAllProjectsIfNecessary();
|
||||
@ -40,6 +46,7 @@ export class AppStateGuard implements CanActivate {
|
||||
await this._router.navigate(['main', 'admin', 'project-templates', ruleSetId]);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user