Skip to content

Commit ca4c52f

Browse files
CopilotHristo313damyanpetev
authored
reactor(igx-ts,side-nav-auth): standalone and angular-auth-oidc-client v21 (#1554)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Hristo313 <57346540+Hristo313@users.noreply.github.com> Co-authored-by: Hristo Hristov <HHristov@infragistics.com> Co-authored-by: damyanpetev <3198469+damyanpetev@users.noreply.github.com>
1 parent 3effa86 commit ca4c52f

34 files changed

Lines changed: 419 additions & 611 deletions

packages/igx-templates/igx-ts/projects/_base/files/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"experimentalDecorators": true,
1414
"importHelpers": true,
1515
"target": "ES2022",
16-
"module": "preserve"
16+
"module": "preserve",
17+
"moduleResolution": "Bundler"
1718
},
1819
"angularCompilerOptions": {
1920
"enableI18nLegacyMessageIdFormat": false,

packages/igx-templates/igx-ts/projects/side-nav-auth/files/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@angular/platform-browser": "~21.2.0",
2020
"@angular/platform-browser-dynamic": "~21.2.0",
2121
"@angular/router": "~21.2.0",
22-
"angular-auth-oidc-client": "~15.0.4",
22+
"angular-auth-oidc-client": "~21.0.1",
2323
"hammerjs": "~2.0.8",
2424
"igniteui-angular": "~21.1.0",
2525
"minireset.css": "~0.0.7",

packages/igx-templates/igx-ts/projects/side-nav-auth/files/src/app/app-module.ts

Lines changed: 0 additions & 48 deletions
This file was deleted.

packages/igx-templates/igx-ts/projects/side-nav-auth/files/src/app/app.config.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
IgxRippleModule,
1010
} from '<%=igxPackage%>';
1111

12-
import { AuthenticationModule, ExternalAuth } from './authentication';
12+
import { provideAuthentication } from './authentication';
1313
import { routes } from './app.routes';
1414

1515
export const appConfig: ApplicationConfig = {
@@ -24,9 +24,12 @@ export const appConfig: ApplicationConfig = {
2424
IgxNavbarModule,
2525
IgxNavigationDrawerModule,
2626
IgxRippleModule,
27-
AuthenticationModule
2827
),
2928
provideAnimations(),
30-
ExternalAuth
29+
provideAuthentication({
30+
// google: { clientId: 'YOUR_GOOGLE_CLIENT_ID' },
31+
// microsoft: { clientId: 'YOUR_MICROSOFT_CLIENT_ID', tenantId: 'YOUR_TENANT_ID' },
32+
// facebook: { clientId: 'YOUR_FACEBOOK_CLIENT_ID' },
33+
})
3134
]
3235
};
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
import { Routes } from '@angular/router';
2+
import { Home } from './home/home';
3+
import { AUTH_ROUTES } from './authentication';
4+
import { AUTH_BASE_PATH } from './authentication/services/external-auth-configs';
25

3-
export const routes: Routes = [];
6+
export const routes: Routes = [
7+
{ path: '', redirectTo: '/home', pathMatch: 'full' },
8+
{ path: 'home', component: Home, data: { text: 'Home' } },
9+
{ path: AUTH_BASE_PATH, children: AUTH_ROUTES }
10+
];

packages/igx-templates/igx-ts/projects/side-nav-auth/files/src/app/app.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
33
import { RouterModule } from '@angular/router';
44
import { IgxLayoutModule, IgxNavbarModule, IgxNavigationDrawerModule, IgxRippleModule } from 'igniteui-angular';
55
import { App } from './app';
6-
import { AuthenticationModule } from './authentication';
6+
import { provideAuthentication } from './authentication/provide-authentication';
77

88
describe('App', () => {
99
beforeEach(async () => {
@@ -12,11 +12,13 @@ describe('App', () => {
1212
NoopAnimationsModule,
1313
RouterModule.forRoot([]),
1414
IgxNavigationDrawerModule,
15-
AuthenticationModule,
1615
IgxNavbarModule,
1716
IgxLayoutModule,
1817
IgxRippleModule,
1918
App
19+
],
20+
providers: [
21+
...provideAuthentication()
2022
]
2123
}).compileComponents();
2224
});

packages/igx-templates/igx-ts/projects/side-nav-auth/files/src/app/authentication/auth.guard.spec.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { AuthGuard } from './auth.guard';
33
describe('AuthGuard', () => {
44
let mockRouter: any;
55
let mockUserService: any;
6+
7+
afterEach(() => { vi.restoreAllMocks(); });
8+
69
beforeEach(() => {
710
mockRouter = {
811
navigate: () => { }
@@ -19,14 +22,14 @@ describe('AuthGuard', () => {
1922

2023
it(`Should properly call 'canActivate'`, () => {
2124
const authGuard = new AuthGuard(mockRouter, mockUserService);
22-
const mockSpy = jasmine.createSpy('mockSpy');
25+
const mockSpy = vi.fn();
2326
expect(authGuard.canActivate(mockSpy as any, mockSpy as any)).toEqual(true);
2427
});
2528
it(`Should properly call 'canActivate'`, () => {
2629
const authGuard = new AuthGuard(mockRouter, mockUserService);
27-
const mockSpy = jasmine.createSpy('mockSpy');
30+
const mockSpy = vi.fn();
2831
mockUserService.currentUser = false;
29-
spyOn(mockRouter, 'navigate');
32+
vi.spyOn(mockRouter, 'navigate');
3033
expect(authGuard.canActivate(mockSpy as any, { url: 'test' } as any)).toEqual(false);
3134
expect(mockRouter.navigate).toHaveBeenCalled();
3235
expect(mockRouter.navigate).toHaveBeenCalledWith([''], { queryParams: { returnUrl: 'test' } });

packages/igx-templates/igx-ts/projects/side-nav-auth/files/src/app/authentication/authentication-routing-module.ts renamed to packages/igx-templates/igx-ts/projects/side-nav-auth/files/src/app/authentication/auth.routes.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,13 @@
1-
import { NgModule } from '@angular/core';
2-
import { RouterModule, Routes } from '@angular/router';
1+
import { Routes } from '@angular/router';
32
import { AuthGuard } from './auth.guard';
43
import { Profile } from './profile/profile';
54
import { Redirect } from './redirect/redirect';
65
import { ExternalAuthProvider } from './services/external-auth-configs';
76
import { ExternalAuthRedirectUrl } from './services/external-auth';
87

9-
const authRoutes: Routes = [
8+
export const AUTH_ROUTES: Routes = [
109
{ path: 'profile', component: Profile, canActivate: [AuthGuard] },
1110
{ path: ExternalAuthRedirectUrl.Google, component: Redirect, data: { provider: ExternalAuthProvider.Google } },
1211
{ path: ExternalAuthRedirectUrl.Facebook, component: Redirect, data: { provider: ExternalAuthProvider.Facebook } },
1312
{ path: ExternalAuthRedirectUrl.Microsoft, component: Redirect, data: { provider: ExternalAuthProvider.Microsoft } }
1413
];
15-
16-
@NgModule({
17-
imports: [
18-
RouterModule.forChild(authRoutes)
19-
],
20-
exports: [
21-
RouterModule
22-
]
23-
})
24-
export class AuthenticationRoutingModule { }

packages/igx-templates/igx-ts/projects/side-nav-auth/files/src/app/authentication/authentication-module.spec.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/igx-templates/igx-ts/projects/side-nav-auth/files/src/app/authentication/authentication-module.ts

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)