refactor: improve type annotations in services and config
Some checks failed
CI / Get Changed Files (pull_request) Successful in 6s
CI / prettier (pull_request) Successful in 23s
CI / Checkstyle Main (pull_request) Successful in 31s
CI / eslint (pull_request) Successful in 1m30s
CI / test-build (pull_request) Failing after 1m43s

This commit is contained in:
Jan K9f 2025-04-02 16:15:31 +02:00
parent 617654caeb
commit d3b7e7d5e7
Signed by: jank
GPG key ID: B9F475106B20F144
3 changed files with 7 additions and 5 deletions

View file

@ -8,9 +8,10 @@ import { provideAnimationsAsync } from '@angular/platform-browser/animations/asy
import { OAuthStorage, provideOAuthClient } from 'angular-oauth2-oidc'; import { OAuthStorage, provideOAuthClient } from 'angular-oauth2-oidc';
import { httpInterceptor } from './shared/interceptor/http.interceptor'; import { httpInterceptor } from './shared/interceptor/http.interceptor';
/* Example of a custom storage factory - not used in the current implementation
function storageFactory() { function storageFactory() {
return new (class implements OAuthStorage { return new (class implements OAuthStorage {
private data: { [key: string]: string } = {}; private data: Record<string, string> = {};
getItem(key: string): string | null { getItem(key: string): string | null {
return this.data[key]; return this.data[key];
@ -25,6 +26,7 @@ function storageFactory() {
} }
})(); })();
} }
*/
export const appConfig: ApplicationConfig = { export const appConfig: ApplicationConfig = {
providers: [ providers: [

View file

@ -109,7 +109,7 @@ export class AuthService {
console.log('Access token:', this.oauthService.getAccessToken()); console.log('Access token:', this.oauthService.getAccessToken());
// Extract claims from id token if available // Extract claims from id token if available
let claims = this.oauthService.getIdentityClaims(); const claims = this.oauthService.getIdentityClaims();
console.log('ID token claims:', claims); console.log('ID token claims:', claims);
// If we have claims, use that as profile // If we have claims, use that as profile
@ -128,7 +128,7 @@ export class AuthService {
console.error('Error loading user profile:', error); console.error('Error loading user profile:', error);
// If we can't load the profile but have a token, create a minimal profile // If we can't load the profile but have a token, create a minimal profile
if (this.oauthService.hasValidAccessToken()) { if (this.oauthService.hasValidAccessToken()) {
const token = this.oauthService.getAccessToken(); this.oauthService.getAccessToken(); // Get token but don't use it directly
// Create a basic profile from the token // Create a basic profile from the token
const minimalProfile = { const minimalProfile = {
sub: 'user-' + Math.random().toString(36).substring(2, 10), sub: 'user-' + Math.random().toString(36).substring(2, 10),
@ -158,7 +158,7 @@ export class AuthService {
} }
} }
private processUserProfile(profile: any) { private processUserProfile(profile: Record<string, unknown>) {
this.fromUserProfile(profile).subscribe({ this.fromUserProfile(profile).subscribe({
next: (user) => { next: (user) => {
console.log('User created/retrieved from backend:', user); console.log('User created/retrieved from backend:', user);

View file

@ -43,7 +43,7 @@ export class UserService {
.pipe(tap((user) => this.currentUserSubject.next(user))); .pipe(tap((user) => this.currentUserSubject.next(user)));
} }
public getOrCreateUser(profile: any): Observable<User> { public getOrCreateUser(profile: Record<string, unknown>): Observable<User> {
console.log('Full authentik profile:', profile); console.log('Full authentik profile:', profile);
// Authentik format might differ from Keycloak // Authentik format might differ from Keycloak
// Check different possible locations for the ID and username // Check different possible locations for the ID and username