Compare commits
No commits in common. "5ab81ee66efe9d06b3d99d849cb01cdb675d3c2c" and "e8f952e7e25872ad7dc86aa666d43097a42cc507" have entirely different histories.
5ab81ee66e
...
e8f952e7e2
|
|
@ -1,6 +1,7 @@
|
||||||
package com.alttd.altitudeweb.database.web_db;
|
package com.alttd.altitudeweb.database.web_db;
|
||||||
|
|
||||||
import org.apache.ibatis.annotations.*;
|
import org.apache.ibatis.annotations.*;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
@ -102,9 +103,9 @@ public interface PrivilegedUserMapper {
|
||||||
int removePermissionFromUser(@Param("userId") int userId, @Param("permission") String permission);
|
int removePermissionFromUser(@Param("userId") int userId, @Param("permission") String permission);
|
||||||
|
|
||||||
@Insert("""
|
@Insert("""
|
||||||
INSERT INTO privileged_users (uuid)
|
INSERT INTO privileged_users (uuid)
|
||||||
VALUES (#{uuid})
|
VALUES (#{uuid})
|
||||||
""")
|
""")
|
||||||
@SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = int.class)
|
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||||
int createPrivilegedUser(UUID uuid);
|
int createPrivilegedUser(UUID uuid);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,27 +118,18 @@ export const routes: Routes = [
|
||||||
path: 'forms',
|
path: 'forms',
|
||||||
loadComponent: () => import('./pages/forms/forms.component').then(m => m.FormsComponent)
|
loadComponent: () => import('./pages/forms/forms.component').then(m => m.FormsComponent)
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: 'appeal/:code',
|
|
||||||
redirectTo: 'forms/appeal/:code',
|
|
||||||
pathMatch: 'full'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: 'appeal',
|
path: 'appeal',
|
||||||
redirectTo: 'forms/appeal',
|
redirectTo: 'forms/appeal',
|
||||||
pathMatch: 'full'
|
pathMatch: 'full'
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: 'forms/appeal/:code',
|
|
||||||
loadComponent: () => import('./pages/forms/appeal/appeal.component').then(m => m.AppealComponent),
|
|
||||||
canActivate: [AuthGuard],
|
|
||||||
data: {requiredAuthorizations: ['SCOPE_user']}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: 'forms/appeal',
|
path: 'forms/appeal',
|
||||||
loadComponent: () => import('./pages/forms/appeal/appeal.component').then(m => m.AppealComponent),
|
loadComponent: () => import('./pages/forms/appeal/appeal.component').then(m => m.AppealComponent),
|
||||||
canActivate: [AuthGuard],
|
canActivate: [AuthGuard],
|
||||||
data: {requiredAuthorizations: ['SCOPE_user']}
|
data: {
|
||||||
|
requiredAuthorizations: ['SCOPE_user']
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'forms/sent',
|
path: 'forms/sent',
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree} from '@angular/router';
|
import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree} from '@angular/router';
|
||||||
import {from, isObservable, map, Observable, of, switchMap} from 'rxjs';
|
import {map, Observable} from 'rxjs';
|
||||||
import {AuthService} from '@services/auth.service';
|
import {AuthService} from '@services/auth.service';
|
||||||
import {MatDialog} from '@angular/material/dialog';
|
import {MatDialog} from '@angular/material/dialog';
|
||||||
import {LoginDialogComponent} from '@shared-components/login/login.component';
|
import {LoginDialogComponent} from '@shared-components/login/login.component';
|
||||||
import {catchError} from 'rxjs/operators';
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
|
|
@ -22,20 +21,6 @@ export class AuthGuard implements CanActivate {
|
||||||
route: ActivatedRouteSnapshot,
|
route: ActivatedRouteSnapshot,
|
||||||
state: RouterStateSnapshot
|
state: RouterStateSnapshot
|
||||||
): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
||||||
const code = route.paramMap.get('code');
|
|
||||||
if (code) {
|
|
||||||
return this.authService.login(code).pipe(
|
|
||||||
switchMap(() => {
|
|
||||||
const result = this.canActivateInternal(route, state);
|
|
||||||
return isObservable(result) ? result : result instanceof Promise ? from(result) : of(result);
|
|
||||||
}),
|
|
||||||
catchError(() => of(this.router.createUrlTree(['/'])))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return this.canActivateInternal(route, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
private canActivateInternal(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
|
||||||
if (!this.authService.isAuthenticated$()) {
|
if (!this.authService.isAuthenticated$()) {
|
||||||
this.router.createUrlTree(['/']);
|
this.router.createUrlTree(['/']);
|
||||||
const dialogRef = this.dialog.open(LoginDialogComponent, {
|
const dialogRef = this.dialog.open(LoginDialogComponent, {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user