initial
This commit is contained in:
63
apps/web/src/main.ts
Normal file
63
apps/web/src/main.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import { HttpInterceptorFn, provideHttpClient, withInterceptors } from '@angular/common/http';
|
||||
import { bootstrapApplication } from '@angular/platform-browser';
|
||||
import { provideRouter, Routes } from '@angular/router';
|
||||
import { AppComponent } from './app/app.component';
|
||||
import { AccountPasswordComponent } from './app/pages/account-password.component';
|
||||
import { AccountOverviewComponent } from './app/pages/account-overview.component';
|
||||
import { AccountEditComponent } from './app/pages/account-edit.component';
|
||||
import { AccountEmailComponent } from './app/pages/account-email.component';
|
||||
import { AdminAuditComponent } from './app/pages/admin-audit.component';
|
||||
import { AdminGroupsComponent } from './app/pages/admin-groups.component';
|
||||
import { AdminOidcClientsComponent } from './app/pages/admin-oidc-clients.component';
|
||||
import { AdminRegistrationsComponent } from './app/pages/admin-registrations.component';
|
||||
import { AdminUsersComponent } from './app/pages/admin-users.component';
|
||||
import { ForgotPasswordComponent } from './app/pages/forgot-password.component';
|
||||
import { LoginComponent } from './app/pages/login.component';
|
||||
import { RegisterComponent } from './app/pages/register.component';
|
||||
import { ResetPasswordComponent } from './app/pages/reset-password.component';
|
||||
import { VerifyEmailComponent } from './app/pages/verify-email.component';
|
||||
import { API_BASE_URL } from './app/shared/api-base-url';
|
||||
import { AuthService } from './app/shared/auth.service';
|
||||
|
||||
const authInterceptor: HttpInterceptorFn = (request, next) => {
|
||||
const token = localStorage.getItem('accessToken');
|
||||
if (!token) {
|
||||
return next(request);
|
||||
}
|
||||
|
||||
return next(
|
||||
request.clone({
|
||||
setHeaders: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', redirectTo: 'login', pathMatch: 'full' },
|
||||
{ path: 'login', component: LoginComponent },
|
||||
{ path: 'register', component: RegisterComponent },
|
||||
{ path: 'verify-email', component: VerifyEmailComponent },
|
||||
{ path: 'forgot-password', component: ForgotPasswordComponent },
|
||||
{ path: 'reset-password', component: ResetPasswordComponent },
|
||||
{ path: 'account', component: AccountOverviewComponent },
|
||||
{ path: 'account/edit', component: AccountEditComponent },
|
||||
{ path: 'account/email', component: AccountEmailComponent },
|
||||
{ path: 'account/password', component: AccountPasswordComponent },
|
||||
{ path: 'admin/oidc-clients', component: AdminOidcClientsComponent },
|
||||
{ path: 'admin/registrations', component: AdminRegistrationsComponent },
|
||||
{ path: 'admin/users', component: AdminUsersComponent },
|
||||
{ path: 'admin/groups', component: AdminGroupsComponent },
|
||||
{ path: 'admin/audit', component: AdminAuditComponent },
|
||||
{ path: '**', redirectTo: 'login' },
|
||||
];
|
||||
|
||||
bootstrapApplication(AppComponent, {
|
||||
providers: [
|
||||
provideRouter(routes),
|
||||
provideHttpClient(withInterceptors([authInterceptor])),
|
||||
AuthService,
|
||||
{ provide: API_BASE_URL, useValue: 'http://localhost:3000' },
|
||||
],
|
||||
}).catch((error) => console.error(error));
|
||||
Reference in New Issue
Block a user