AI Implementation feature(842): First-Start Create Admin Modal 1.01 (#4)
This commit was merged in pull request #4.
This commit is contained in:
@@ -2,17 +2,24 @@ import { inject } from '@angular/core';
|
||||
import { CanActivateFn, Router } from '@angular/router';
|
||||
import { AuthService } from '../services/auth.service';
|
||||
import { BootstrapService } from '../services/bootstrap.service';
|
||||
import { decideAuthRedirect } from './auth.guard.decision';
|
||||
|
||||
export const authGuard: CanActivateFn = () => {
|
||||
export { decideAuthRedirect } from './auth.guard.decision';
|
||||
export type { AuthGuardInput } from './auth.guard.decision';
|
||||
|
||||
export const authGuard: CanActivateFn = async () => {
|
||||
const auth = inject(AuthService);
|
||||
const bootstrap = inject(BootstrapService);
|
||||
const router = inject(Router);
|
||||
|
||||
if (!bootstrap.initialized()) {
|
||||
return router.createUrlTree(['/bootstrap']);
|
||||
}
|
||||
if (!auth.isAuthenticated()) {
|
||||
return router.createUrlTree(['/login']);
|
||||
}
|
||||
return true;
|
||||
await bootstrap.ready();
|
||||
await auth.waitUntilHydrated();
|
||||
|
||||
return decideAuthRedirect(
|
||||
{
|
||||
initialized: bootstrap.initialized(),
|
||||
isAuthenticated: auth.isAuthenticated(),
|
||||
},
|
||||
router,
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user