Skip to content

Commit ad5db64

Browse files
committed
fix(igx-ts): fix login
1 parent 8355531 commit ad5db64

6 files changed

Lines changed: 25 additions & 14 deletions

File tree

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.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ export class App implements OnInit {
5858
* To register a social login, un-comment one or more of the following and add your service provider Client ID.
5959
* See https://github.com/IgniteUI/igniteui-cli/wiki/Angular-Authentication-Project-Template#add-a-third-party-social-provider
6060
*/
61-
// this.externalAuth.addGoogle('CLIENT_ID');
62-
// this.externalAuth.addMicrosoft('CLIENT_ID');
61+
// this.externalAuth.addGoogle();
62+
// this.externalAuth.addMicrosoft();
6363
// this.externalAuth.addFacebook('CLIENT_ID');
6464
}
6565

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
2-
import { EnvironmentProviders, importProvidersFrom, Provider } from '@angular/core';
3-
import { AuthModule } from 'angular-auth-oidc-client';
2+
import { EnvironmentProviders, Provider } from '@angular/core';
3+
import { provideAuth } from 'angular-auth-oidc-client';
44

55
import { BackendProvider } from './services/fake-backend';
66
import { JwtInterceptor } from './services/jwt.interceptor';
77

88
/** Provides all authentication-related dependencies (OIDC, JWT interceptor, fake backend). */
99
export function provideAuthentication(): Array<Provider | EnvironmentProviders> {
1010
return [
11-
importProvidersFrom(AuthModule.forRoot({ config: [] })),
11+
provideAuth({
12+
config: {
13+
// authority: '<your OIDC authority URL>',
14+
// redirectUrl: '<your redirect URL>',
15+
// postLogoutRedirectUri: window.location.origin,
16+
// clientId: '<your client ID>',
17+
// scope: 'openid profile email offline_access',
18+
// responseType: 'code',
19+
// silentRenew: true,
20+
// useRefreshToken: true
21+
},
22+
}),
1223
provideHttpClient(withInterceptorsFromDi()),
1324
{ provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
1425
// BackendProvider intercepts HTTP requests and simulates a REST API for development/testing.

packages/igx-templates/igx-ts/projects/side-nav-auth/files/src/app/authentication/providers/base-oidc-provider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export abstract class BaseOidcProvider implements AuthProvider {
1010
protected configId: string) { }
1111

1212
public login() {
13-
this.oidcSecurityService.authorize(this.configId);
13+
this.oidcSecurityService.authorize();
1414
}
1515

1616
public async getUserInfo(): Promise<ExternalLogin> {
@@ -25,7 +25,7 @@ export abstract class BaseOidcProvider implements AuthProvider {
2525
}
2626

2727
public logout() {
28-
this.oidcSecurityService.logoff(this.configId);
28+
this.oidcSecurityService.logoff().subscribe();
2929
}
3030

3131
/** Format received user data per provider claims */

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ export class ExternalAuth {
4242
return this.providers.size > 0;
4343
}
4444

45-
public addGoogle(clientID: string) {
45+
public addGoogle() {
4646
this.providers.set(
4747
ExternalAuthProvider.Google,
48-
new GoogleProvider(this.oidcSecurityService, clientID)
48+
new GoogleProvider(this.oidcSecurityService, ExternalAuthProvider.Google)
4949
);
5050
}
5151

@@ -61,10 +61,10 @@ export class ExternalAuth {
6161
);
6262
}
6363

64-
public addMicrosoft(clientID: string) {
64+
public addMicrosoft() {
6565
this.providers.set(
6666
ExternalAuthProvider.Microsoft,
67-
new MicrosoftProvider(this.oidcSecurityService, clientID)
67+
new MicrosoftProvider(this.oidcSecurityService, ExternalAuthProvider.Microsoft)
6868
);
6969
}
7070

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ describe('Services', () => {
109109

110110
it(`Should properly call 'addGoogle'`, () => {
111111
const providersSpy = vi.spyOn((extAuthServ as any).providers, 'set');
112-
extAuthServ.addGoogle('test');
112+
extAuthServ.addGoogle();
113113
expect(providersSpy).toHaveBeenCalled();
114114
expect(providersSpy).toHaveBeenCalledWith('Google',
115115
new GoogleProvider(MOCK_OIDC_SECURITY, 'test'));
@@ -129,7 +129,7 @@ describe('Services', () => {
129129

130130
it(`Should properly call 'addMicrosoft'`, () => {
131131
const providersSpy = vi.spyOn((extAuthServ as any).providers, 'set');
132-
extAuthServ.addMicrosoft('test');
132+
extAuthServ.addMicrosoft();
133133
expect(providersSpy).toHaveBeenCalled();
134134
expect(providersSpy).toHaveBeenCalledWith('Microsoft',
135135
new MicrosoftProvider(MOCK_OIDC_SECURITY, 'test'));

0 commit comments

Comments
 (0)