Skip to content

Commit

Permalink
Add auth guard logic to protect routes based on public key presence
Browse files Browse the repository at this point in the history
  • Loading branch information
miladsoft committed Sep 13, 2024
1 parent af90ec8 commit b3684fd
Show file tree
Hide file tree
Showing 38 changed files with 280 additions and 2,060 deletions.
2 changes: 0 additions & 2 deletions src/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
import { provideAngor } from '@angor';
import { TranslocoService, provideTransloco } from '@ngneat/transloco';
import { appRoutes } from 'app/app.routes';
import { provideAuth } from 'app/core/auth/auth.provider';
import { provideIcons } from 'app/core/icons/icons.provider';
import { mockApiServices } from 'app/mock-api';
import { firstValueFrom } from 'rxjs';
Expand Down Expand Up @@ -81,7 +80,6 @@ export const appConfig: ApplicationConfig = {
},

// Angor Configuration
provideAuth(),
provideIcons(),
provideAngor({
mockApi: {
Expand Down
49 changes: 15 additions & 34 deletions src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Route } from '@angular/router';
import { initialDataResolver } from 'app/app.resolvers';
import { AuthGuard } from 'app/core/auth/guards/auth.guard';
import { NoAuthGuard } from 'app/core/auth/guards/noAuth.guard';
import { LayoutComponent } from 'app/layout/layout.component';
import { LayoutComponent } from 'app/layout/layout.component';
import { authGuard } from './core/auth/auth.guard';

/**
* Application routes configuration
Expand All @@ -13,62 +12,44 @@ export const appRoutes: Route[] = [
{
path: '',
pathMatch: 'full',
redirectTo: 'explore'
redirectTo: 'home'
},

// Redirect signed-in user to '/explore'
// Redirect login user to '/explore'
{
path: 'signed-in-redirect',
path: 'login-redirect',
pathMatch: 'full',
redirectTo: 'explore'
},

// Routes for guests
{
path: '',
canActivate: [NoAuthGuard],
canActivateChild: [NoAuthGuard],
component: LayoutComponent,
data: { layout: 'empty' },
children: [
{
path: 'confirmation-required',
loadChildren: () => import('app/components/auth/confirmation-required/confirmation-required.routes')
},
{
path: 'forgot-password',
loadChildren: () => import('app/components/auth/forgot-password/forgot-password.routes')
},
{
path: 'reset-password',
loadChildren: () => import('app/components/auth/reset-password/reset-password.routes')
path: 'login',
loadChildren: () => import('app/components/auth/login/login.routes')
},
{
path: 'sign-in',
loadChildren: () => import('app/components/auth/sign-in/sign-in.routes')
},
{
path: 'sign-up',
loadChildren: () => import('app/components/auth/sign-up/sign-up.routes')
path: 'register',
loadChildren: () => import('app/components/auth/register/register.routes')
}
]
},

// Routes for authenticated users
{
path: '',
canActivate: [AuthGuard],
canActivateChild: [AuthGuard],
canActivate: [authGuard],
canActivateChild: [authGuard],
component: LayoutComponent,
data: { layout: 'empty' },
children: [
{
path: 'sign-out',
loadChildren: () => import('app/components/auth/sign-out/sign-out.routes')
},
{
path: 'unlock-session',
loadChildren: () => import('app/components/auth/unlock-session/unlock-session.routes')
path: 'logout',
loadChildren: () => import('app/components/auth/logout/logout.routes')
}
]
},
Expand All @@ -78,8 +59,8 @@ export const appRoutes: Route[] = [
// Authenticated routes for Angor
{
path: '',
canActivate: [AuthGuard],
canActivateChild: [AuthGuard],
canActivate: [authGuard],
canActivateChild: [authGuard],
component: LayoutComponent,
resolve: { initialData: initialDataResolver },
children: [
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

147 changes: 0 additions & 147 deletions src/app/components/auth/forgot-password/forgot-password.component.html

This file was deleted.

Loading

0 comments on commit b3684fd

Please sign in to comment.