Skip to content

Commit e099dee

Browse files
Updating es lint rules and removing newline between injects
1 parent c418a91 commit e099dee

File tree

42 files changed

+2773
-2920
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2773
-2920
lines changed

projects/angular-auth-oidc-client/src/lib/auth-state/auth-state.service.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@ export class AuthStateService {
2121
private readonly storagePersistenceService = inject(
2222
StoragePersistenceService
2323
);
24-
2524
private readonly loggerService = inject(LoggerService);
26-
2725
private readonly publicEventsService = inject(PublicEventsService);
28-
2926
private readonly tokenValidationService = inject(TokenValidationService);
3027

3128
private readonly authenticatedInternal$ =

projects/angular-auth-oidc-client/src/lib/auto-login/auto-login-all-routes.guard.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable, inject } from '@angular/core';
1+
import { inject, Injectable } from '@angular/core';
22
import {
33
ActivatedRouteSnapshot,
44
Router,
@@ -18,13 +18,9 @@ import { AutoLoginService } from './auto-login.service';
1818
@Injectable({ providedIn: 'root' })
1919
export class AutoLoginAllRoutesGuard {
2020
private readonly autoLoginService = inject(AutoLoginService);
21-
2221
private readonly checkAuthService = inject(CheckAuthService);
23-
2422
private readonly loginService = inject(LoginService);
25-
2623
private readonly configurationService = inject(ConfigurationService);
27-
2824
private readonly router = inject(Router);
2925

3026
canLoad(): Observable<boolean> {
Lines changed: 143 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -1,146 +1,143 @@
1-
import { Injectable, inject } from '@angular/core';
2-
import {
3-
ActivatedRouteSnapshot,
4-
Router,
5-
RouterStateSnapshot,
6-
} from '@angular/router';
7-
import { Observable } from 'rxjs';
8-
import { map } from 'rxjs/operators';
9-
import { AuthOptions } from '../auth-options';
10-
import { AuthStateService } from '../auth-state/auth-state.service';
11-
import { ConfigurationService } from '../config/config.service';
12-
import { LoginService } from '../login/login.service';
13-
import { AutoLoginService } from './auto-login.service';
14-
15-
@Injectable({ providedIn: 'root' })
16-
export class AutoLoginPartialRoutesGuard {
17-
private readonly autoLoginService = inject(AutoLoginService);
18-
19-
private readonly authStateService = inject(AuthStateService);
20-
21-
private readonly loginService = inject(LoginService);
22-
23-
private readonly configurationService = inject(ConfigurationService);
24-
25-
private readonly router = inject(Router);
26-
27-
canLoad(): Observable<boolean> {
28-
const url =
29-
this.router
30-
.getCurrentNavigation()
31-
?.extractedUrl.toString()
32-
.substring(1) ?? '';
33-
34-
return checkAuth(
35-
url,
36-
this.configurationService,
37-
this.authStateService,
38-
this.autoLoginService,
39-
this.loginService
40-
);
41-
}
42-
43-
canActivate(
44-
route: ActivatedRouteSnapshot,
45-
state: RouterStateSnapshot
46-
): Observable<boolean> {
47-
const authOptions: AuthOptions | undefined = route?.data
48-
? { customParams: route.data }
49-
: undefined;
50-
51-
return checkAuth(
52-
state.url,
53-
this.configurationService,
54-
this.authStateService,
55-
this.autoLoginService,
56-
this.loginService,
57-
authOptions
58-
);
59-
}
60-
61-
canActivateChild(
62-
route: ActivatedRouteSnapshot,
63-
state: RouterStateSnapshot
64-
): Observable<boolean> {
65-
const authOptions: AuthOptions | undefined = route?.data
66-
? { customParams: route.data }
67-
: undefined;
68-
69-
return checkAuth(
70-
state.url,
71-
this.configurationService,
72-
this.authStateService,
73-
this.autoLoginService,
74-
this.loginService,
75-
authOptions
76-
);
77-
}
78-
}
79-
80-
export function autoLoginPartialRoutesGuard(
81-
route?: ActivatedRouteSnapshot,
82-
state?: RouterStateSnapshot,
83-
configId?: string
84-
): Observable<boolean> {
85-
const configurationService = inject(ConfigurationService);
86-
const authStateService = inject(AuthStateService);
87-
const loginService = inject(LoginService);
88-
const autoLoginService = inject(AutoLoginService);
89-
const router = inject(Router);
90-
const authOptions: AuthOptions | undefined = route?.data
91-
? { customParams: route.data }
92-
: undefined; const url =
93-
router.getCurrentNavigation()?.extractedUrl.toString().substring(1) ?? '';
94-
95-
return checkAuth(
96-
url,
97-
configurationService,
98-
authStateService,
99-
autoLoginService,
100-
loginService,
101-
authOptions,
102-
configId
103-
);
104-
}
105-
106-
export function autoLoginPartialRoutesGuardWithConfig(
107-
configId: string
108-
): (
109-
route?: ActivatedRouteSnapshot,
110-
state?: RouterStateSnapshot
111-
) => Observable<boolean> {
112-
return (route?: ActivatedRouteSnapshot, state?: RouterStateSnapshot) =>
113-
autoLoginPartialRoutesGuard(route, state, configId);
114-
}
115-
116-
function checkAuth(
117-
url: string,
118-
configurationService: ConfigurationService,
119-
authStateService: AuthStateService,
120-
autoLoginService: AutoLoginService,
121-
loginService: LoginService,
122-
authOptions?: AuthOptions,
123-
configId?: string
124-
): Observable<boolean> {
125-
return configurationService.getOpenIDConfiguration(configId).pipe(
126-
map((configuration) => {
127-
const isAuthenticated =
128-
authStateService.areAuthStorageTokensValid(configuration);
129-
130-
if (isAuthenticated) {
131-
autoLoginService.checkSavedRedirectRouteAndNavigate(configuration);
132-
}
133-
134-
if (!isAuthenticated) {
135-
autoLoginService.saveRedirectRoute(configuration, url);
136-
if (authOptions) {
137-
loginService.login(configuration, authOptions);
138-
} else {
139-
loginService.login(configuration);
140-
}
141-
}
142-
143-
return isAuthenticated;
144-
})
145-
);
146-
}
1+
import { inject, Injectable } from '@angular/core';
2+
import {
3+
ActivatedRouteSnapshot,
4+
Router,
5+
RouterStateSnapshot,
6+
} from '@angular/router';
7+
import { Observable } from 'rxjs';
8+
import { map } from 'rxjs/operators';
9+
import { AuthOptions } from '../auth-options';
10+
import { AuthStateService } from '../auth-state/auth-state.service';
11+
import { ConfigurationService } from '../config/config.service';
12+
import { LoginService } from '../login/login.service';
13+
import { AutoLoginService } from './auto-login.service';
14+
15+
@Injectable({ providedIn: 'root' })
16+
export class AutoLoginPartialRoutesGuard {
17+
private readonly autoLoginService = inject(AutoLoginService);
18+
private readonly authStateService = inject(AuthStateService);
19+
private readonly loginService = inject(LoginService);
20+
private readonly configurationService = inject(ConfigurationService);
21+
private readonly router = inject(Router);
22+
23+
canLoad(): Observable<boolean> {
24+
const url =
25+
this.router
26+
.getCurrentNavigation()
27+
?.extractedUrl.toString()
28+
.substring(1) ?? '';
29+
30+
return checkAuth(
31+
url,
32+
this.configurationService,
33+
this.authStateService,
34+
this.autoLoginService,
35+
this.loginService
36+
);
37+
}
38+
39+
canActivate(
40+
route: ActivatedRouteSnapshot,
41+
state: RouterStateSnapshot
42+
): Observable<boolean> {
43+
const authOptions: AuthOptions | undefined = route?.data
44+
? { customParams: route.data }
45+
: undefined;
46+
47+
return checkAuth(
48+
state.url,
49+
this.configurationService,
50+
this.authStateService,
51+
this.autoLoginService,
52+
this.loginService,
53+
authOptions
54+
);
55+
}
56+
57+
canActivateChild(
58+
route: ActivatedRouteSnapshot,
59+
state: RouterStateSnapshot
60+
): Observable<boolean> {
61+
const authOptions: AuthOptions | undefined = route?.data
62+
? { customParams: route.data }
63+
: undefined;
64+
65+
return checkAuth(
66+
state.url,
67+
this.configurationService,
68+
this.authStateService,
69+
this.autoLoginService,
70+
this.loginService,
71+
authOptions
72+
);
73+
}
74+
}
75+
76+
export function autoLoginPartialRoutesGuard(
77+
route?: ActivatedRouteSnapshot,
78+
state?: RouterStateSnapshot,
79+
configId?: string
80+
): Observable<boolean> {
81+
const configurationService = inject(ConfigurationService);
82+
const authStateService = inject(AuthStateService);
83+
const loginService = inject(LoginService);
84+
const autoLoginService = inject(AutoLoginService);
85+
const router = inject(Router);
86+
const authOptions: AuthOptions | undefined = route?.data
87+
? { customParams: route.data }
88+
: undefined;
89+
const url =
90+
router.getCurrentNavigation()?.extractedUrl.toString().substring(1) ?? '';
91+
92+
return checkAuth(
93+
url,
94+
configurationService,
95+
authStateService,
96+
autoLoginService,
97+
loginService,
98+
authOptions,
99+
configId
100+
);
101+
}
102+
103+
export function autoLoginPartialRoutesGuardWithConfig(
104+
configId: string
105+
): (
106+
route?: ActivatedRouteSnapshot,
107+
state?: RouterStateSnapshot
108+
) => Observable<boolean> {
109+
return (route?: ActivatedRouteSnapshot, state?: RouterStateSnapshot) =>
110+
autoLoginPartialRoutesGuard(route, state, configId);
111+
}
112+
113+
function checkAuth(
114+
url: string,
115+
configurationService: ConfigurationService,
116+
authStateService: AuthStateService,
117+
autoLoginService: AutoLoginService,
118+
loginService: LoginService,
119+
authOptions?: AuthOptions,
120+
configId?: string
121+
): Observable<boolean> {
122+
return configurationService.getOpenIDConfiguration(configId).pipe(
123+
map((configuration) => {
124+
const isAuthenticated =
125+
authStateService.areAuthStorageTokensValid(configuration);
126+
127+
if (isAuthenticated) {
128+
autoLoginService.checkSavedRedirectRouteAndNavigate(configuration);
129+
}
130+
131+
if (!isAuthenticated) {
132+
autoLoginService.saveRedirectRoute(configuration, url);
133+
if (authOptions) {
134+
loginService.login(configuration, authOptions);
135+
} else {
136+
loginService.login(configuration);
137+
}
138+
}
139+
140+
return isAuthenticated;
141+
})
142+
);
143+
}

projects/angular-auth-oidc-client/src/lib/auto-login/auto-login.service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable, inject } from '@angular/core';
1+
import { inject, Injectable } from '@angular/core';
22
import { Router } from '@angular/router';
33
import { OpenIdConfiguration } from '../config/openid-configuration';
44
import { StoragePersistenceService } from '../storage/storage-persistence.service';
@@ -8,7 +8,6 @@ const STORAGE_KEY = 'redirect';
88
@Injectable({ providedIn: 'root' })
99
export class AutoLoginService {
1010
private readonly storageService = inject(StoragePersistenceService);
11-
1211
private readonly router = inject(Router);
1312

1413
checkSavedRedirectRouteAndNavigate(config: OpenIdConfiguration | null): void {

projects/angular-auth-oidc-client/src/lib/callback/callback.service.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable, inject } from '@angular/core';
1+
import { inject, Injectable } from '@angular/core';
22
import { Observable, Subject } from 'rxjs';
33
import { tap } from 'rxjs/operators';
44
import { OpenIdConfiguration } from '../config/openid-configuration';
@@ -11,13 +11,10 @@ import { ImplicitFlowCallbackService } from './implicit-flow-callback.service';
1111
@Injectable({ providedIn: 'root' })
1212
export class CallbackService {
1313
private readonly urlService = inject(UrlService);
14-
1514
private readonly flowHelper = inject(FlowHelper);
16-
1715
private readonly implicitFlowCallbackService = inject(
1816
ImplicitFlowCallbackService
1917
);
20-
2118
private readonly codeFlowCallbackService = inject(CodeFlowCallbackService);
2219

2320
private readonly stsCallbackInternal$ = new Subject<void>();

0 commit comments

Comments
 (0)