RED-5482: fix redirects
This commit is contained in:
parent
1b37e26a35
commit
3e0d9676e8
@ -114,13 +114,7 @@ const routes: IqserRoutes = [
|
||||
{
|
||||
path: 'admin',
|
||||
loadChildren: () => import('./modules/admin/admin.module').then(m => m.AdminModule),
|
||||
canActivate: [IqserPermissionsGuard],
|
||||
data: {
|
||||
permissions: {
|
||||
allow: [ROLES.templates.read],
|
||||
redirectTo: '/auth-error',
|
||||
},
|
||||
},
|
||||
canActivate: [RedRoleGuard],
|
||||
},
|
||||
{
|
||||
path: 'dashboard',
|
||||
@ -140,7 +134,11 @@ const routes: IqserRoutes = [
|
||||
ROLES.notifications.read,
|
||||
'RED_USER',
|
||||
],
|
||||
redirectTo: '/auth-error',
|
||||
redirectTo: {
|
||||
RED_USER: '/main/admin',
|
||||
[ROLES.templates.read]: '/main/admin',
|
||||
[DEFAULT_REDIRECT_KEY]: '/auth-error',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -202,6 +200,7 @@ const routes: IqserRoutes = [
|
||||
],
|
||||
redirectTo: {
|
||||
[ROLES.any]: '/auth-error',
|
||||
RED_USER: '/main/admin',
|
||||
[DEFAULT_REDIRECT_KEY]: '/',
|
||||
},
|
||||
},
|
||||
|
||||
@ -7,7 +7,7 @@ import { ReanalysisService } from '@services/reanalysis.service';
|
||||
import { ExcludedPagesService } from '../../services/excluded-pages.service';
|
||||
import { combineLatest, firstValueFrom, Observable } from 'rxjs';
|
||||
import { FilePreviewStateService } from '../../services/file-preview-state.service';
|
||||
import { map, pluck } from 'rxjs/operators';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { extractPageRanges } from '@utils/page-ranges-mapper';
|
||||
|
||||
@Component({
|
||||
@ -39,7 +39,7 @@ export class PageExclusionComponent {
|
||||
|
||||
private get _excludedRanges$() {
|
||||
return this._state.file$.pipe(
|
||||
pluck('excludedPages'),
|
||||
map(file => file.excludedPages),
|
||||
map(pages => pages.sort((p1, p2) => p1 - p2)),
|
||||
map(pages => this._toPageRange(pages)),
|
||||
shareLast(),
|
||||
|
||||
@ -2,7 +2,6 @@ import { inject, Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
|
||||
import { UserService } from './user.service';
|
||||
import { IqserPermissionsService, IqserRoleGuard } from '@iqser/common-ui';
|
||||
import { ROLES } from '@users/roles';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@ -14,7 +13,7 @@ export class RedRoleGuard extends IqserRoleGuard {
|
||||
async canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
|
||||
const currentUser = this._userService.currentUser;
|
||||
|
||||
if (!this._permissionsService.has(ROLES.any)) {
|
||||
if (!currentUser.hasAnyRole) {
|
||||
await this._router.navigate(['/auth-error']);
|
||||
this._loadingService.stop();
|
||||
return false;
|
||||
|
||||
@ -17,7 +17,7 @@ export class UserService extends IqserUserService<IIqserUser, User> {
|
||||
this._permissionsService.add({
|
||||
[ROLES.any]: (permission, all) => {
|
||||
console.log('all roles: ', Object.keys(all));
|
||||
return Object.keys(all).some(key => key.startsWith('red-') || key.startsWith('RED_'));
|
||||
return Object.keys(all).some(key => this._permissionsFilter(key));
|
||||
},
|
||||
});
|
||||
|
||||
@ -40,7 +40,8 @@ export class UserService extends IqserUserService<IIqserUser, User> {
|
||||
return this._post(null, `${this._defaultModelPath}/profile/activate/${user.userId}`, queryParams);
|
||||
}
|
||||
|
||||
protected readonly _rolesFilter = (role: string) => role.startsWith('RED_') || role.startsWith('red-');
|
||||
protected readonly _rolesFilter = (role: string) => role.startsWith('RED_');
|
||||
protected readonly _permissionsFilter = (role: string) => role.startsWith('red-');
|
||||
}
|
||||
|
||||
export function getCurrentUser() {
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit 2f10819460065591e726c839175002b73ca75a3d
|
||||
Subproject commit c744c738451af53ca665b97cc99534bede42a7d4
|
||||
@ -3013,11 +3013,6 @@
|
||||
d3-transition "^2.0.0"
|
||||
tslib "^2.0.0"
|
||||
|
||||
"@tabuckner/material-dayjs-adapter@2.0.0":
|
||||
version "2.0.0"
|
||||
resolved "https://registry.npmjs.org/@tabuckner/material-dayjs-adapter/-/material-dayjs-adapter-2.0.0.tgz"
|
||||
integrity sha512-U2h76Gid/9sWXo+CxxQFnkMpOxfGiSH2xnHDHUmI9ZHZjTzOQ3/T7bZl9jIh43eBEwM3E4mba5W8NYvKExtzaA==
|
||||
|
||||
"@tootallnate/once@1":
|
||||
version "1.1.2"
|
||||
resolved "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user