Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions frontend/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { provideZxvbnServiceForPSM } from 'angular-password-strength-meter/zxcvbn';
import { AuthGuard } from './auth.guard';
import { AuthGuard } from './guards/auth.guard';
import { configurationGuard } from './guards/configuration.guard';
import { noAuthGuard } from './guards/no-auth.guard';
import { setupGuard } from './guards/setup.guard';

const routes: Routes = [
{ path: '', redirectTo: '/connections-list', pathMatch: 'full' },

Copilot AI Apr 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The /loader route was removed from the router config, but AppComponent still sets redirect_uri to ${location.origin}/loader (frontend/src/app/app.component.ts:68). If this is used as an OAuth/SSO redirect, removing the route will cause a 404/broken login flow; either restore the /loader route or update the redirect URI to an existing route.

Suggested change
{ path: '', redirectTo: '/connections-list', pathMatch: 'full' },
{ path: '', redirectTo: '/connections-list', pathMatch: 'full' },
{ path: 'loader', redirectTo: '/login', pathMatch: 'full' },

Copilot uses AI. Check for mistakes.
{
path: 'loader',
loadComponent: () => import('./components/page-loader/page-loader.component').then((m) => m.PageLoaderComponent),
},
{
path: 'registration',
loadChildren: () => import('./routes/registration.routes').then((m) => m.REGISTRATION_ROUTES),
canActivate: [noAuthGuard],
},
{
path: 'setup',
Expand All @@ -25,7 +23,7 @@ const routes: Routes = [
{
path: 'login',
loadComponent: () => import('./components/login/login.component').then((m) => m.LoginComponent),
canActivate: [configurationGuard],
canActivate: [noAuthGuard, configurationGuard],
title: 'Login | Rocketadmin',
},
{
Expand Down
File renamed without changes.
26 changes: 26 additions & 0 deletions frontend/src/app/guards/no-auth.guard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { CanActivateFn, Router } from '@angular/router';
import { inject } from '@angular/core';
import { differenceInMilliseconds } from 'date-fns';

/**
* Guard that prevents logged-in users from accessing auth pages (login, registration).
* Redirects authenticated users to /connections-list.
*/
export const noAuthGuard: CanActivateFn = () => {
const router = inject(Router);

try {
const expirationToken = localStorage.getItem('token_expiration');
if (expirationToken) {
const expirationTime = new Date(expirationToken);
const expirationInterval = differenceInMilliseconds(expirationTime, new Date());
if (expirationInterval > 0) {
return router.createUrlTree(['/connections-list']);
}
}
} catch {
// If anything fails, allow access to auth pages
}

return true;
};
2 changes: 1 addition & 1 deletion frontend/src/app/routes/password-change.routes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Routes } from '@angular/router';
import { provideZxvbnServiceForPSM } from 'angular-password-strength-meter/zxcvbn';
import { AuthGuard } from '../auth.guard';
import { AuthGuard } from '../guards/auth.guard';

export const PASSWORD_CHANGE_ROUTES: Routes = [
{
Expand Down
Loading