-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
752 additions
and
502 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"bracketSpacing": true, | ||
"semi": false, | ||
"singleQuote": true, | ||
"trailingComma": "es5", | ||
"printWidth": 80 | ||
} | ||
"bracketSpacing": true, | ||
"semi": false, | ||
"singleQuote": true, | ||
"trailingComma": "es5", | ||
"printWidth": 80 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,12 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { LoginComponent } from './login/login.component'; | ||
import { RouterModule, Routes } from '@angular/router'; | ||
import { ReactiveFormsModule } from '@angular/forms'; | ||
import { routes } from './account.route'; | ||
import { NgModule } from '@angular/core' | ||
import { CommonModule } from '@angular/common' | ||
import { LoginComponent } from './login/login.component' | ||
import { RouterModule, Routes } from '@angular/router' | ||
import { ReactiveFormsModule } from '@angular/forms' | ||
import { routes } from './account.route' | ||
|
||
@NgModule({ | ||
declarations: [ | ||
LoginComponent | ||
], | ||
imports: [ | ||
CommonModule, | ||
ReactiveFormsModule, | ||
RouterModule.forChild(routes) | ||
] | ||
declarations: [LoginComponent], | ||
imports: [CommonModule, ReactiveFormsModule, RouterModule.forChild(routes)], | ||
}) | ||
export class AccountModule { } | ||
export class AccountModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
import { Routes } from "@angular/router"; | ||
import { LoginComponent } from "./login/login.component"; | ||
import { AuthGuard } from "./auth.guard"; | ||
import { HomeComponent } from "../home/home.component"; | ||
import { Routes } from '@angular/router' | ||
import { LoginComponent } from './login/login.component' | ||
import { AuthGuard } from './auth.guard' | ||
import { HomeComponent } from '../home/home.component' | ||
|
||
export const routes: Routes = [ | ||
{ | ||
path: 'login', | ||
component: LoginComponent | ||
} | ||
]; | ||
|
||
{ | ||
path: 'login', | ||
component: LoginComponent, | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,42 @@ | ||
import { inject } from '@angular/core'; | ||
import { ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router'; | ||
import { inject } from '@angular/core' | ||
import { | ||
ActivatedRouteSnapshot, | ||
Router, | ||
RouterStateSnapshot, | ||
} from '@angular/router' | ||
|
||
import { StateStorageService } from './service/state-storage.service' | ||
import { AccountService } from './service/account.service' | ||
import { Observable, filter, map, take } from 'rxjs' | ||
|
||
import { StateStorageService } from './service/state-storage.service'; | ||
import { AccountService } from './service/account.service'; | ||
import { Observable, filter, map, take } from 'rxjs'; | ||
export const AuthGuard = ( | ||
route: ActivatedRouteSnapshot, | ||
state: RouterStateSnapshot | ||
): Observable<boolean> | boolean => { | ||
const authorities = route.data['authorities'] | ||
|
||
export const AuthGuard = (route: ActivatedRouteSnapshot, | ||
state: RouterStateSnapshot): Observable<boolean> | boolean => { | ||
const authorities = route.data['authorities']; | ||
|
||
const router = inject(Router); | ||
const accountService = inject(AccountService); | ||
const router = inject(Router) | ||
const accountService = inject(AccountService) | ||
const stateStorageService = inject(StateStorageService) | ||
|
||
return accountService.getAccountData().pipe(filter(account => account !== undefined),map(account => { | ||
console.log(authorities, account); | ||
return accountService.getAccountData().pipe( | ||
filter((account) => account !== undefined), | ||
map((account) => { | ||
console.log(authorities, account) | ||
|
||
if (account) { | ||
const hasAnyAuthority = accountService.hasAnyAuthority(authorities); | ||
if (hasAnyAuthority) { | ||
return true; | ||
if (account) { | ||
const hasAnyAuthority = accountService.hasAnyAuthority(authorities) | ||
if (hasAnyAuthority) { | ||
return true | ||
} else { | ||
router.navigate(['accessdenied']) | ||
return false | ||
} | ||
} else { | ||
router.navigate(['accessdenied']); | ||
return false; | ||
router.navigate(['/login']) | ||
stateStorageService.storeUrl(state.url) | ||
return false | ||
} | ||
} else { | ||
router.navigate(['/login']); | ||
stateStorageService.storeUrl(state.url); | ||
return false; | ||
} | ||
})); | ||
}) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.