refactor: update imports and type definitions in services
Some checks failed
Some checks failed
This commit is contained in:
parent
d3b7e7d5e7
commit
e37dcecd3f
4 changed files with 12 additions and 10 deletions
|
@ -158,8 +158,8 @@ export class AuthService {
|
|||
}
|
||||
}
|
||||
|
||||
private processUserProfile(profile: Record<string, unknown>) {
|
||||
this.fromUserProfile(profile).subscribe({
|
||||
private processUserProfile(profile: unknown) {
|
||||
this.fromUserProfile(profile as Record<string, unknown>).subscribe({
|
||||
next: (user) => {
|
||||
console.log('User created/retrieved from backend:', user);
|
||||
this.user = user;
|
||||
|
@ -225,7 +225,7 @@ export class AuthService {
|
|||
return this.oauthService.hasValidAccessToken();
|
||||
}
|
||||
|
||||
private fromUserProfile(profile: object) {
|
||||
private fromUserProfile(profile: Record<string, unknown>) {
|
||||
return this.userService.getOrCreateUser(profile);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,12 +47,13 @@ export class UserService {
|
|||
console.log('Full authentik profile:', profile);
|
||||
// Authentik format might differ from Keycloak
|
||||
// Check different possible locations for the ID and username
|
||||
const id = profile.info?.sub || profile['sub'];
|
||||
const info = profile['info'] as Record<string, unknown> | undefined;
|
||||
const id = info?.['sub'] as string || profile['sub'] as string;
|
||||
const username =
|
||||
profile.info?.preferred_username ||
|
||||
profile['preferred_username'] ||
|
||||
profile['email'] ||
|
||||
profile['name'];
|
||||
info?.['preferred_username'] as string ||
|
||||
profile['preferred_username'] as string ||
|
||||
profile['email'] as string ||
|
||||
profile['name'] as string;
|
||||
|
||||
if (!id || !username) {
|
||||
console.error('Could not extract user ID or username from profile', profile);
|
||||
|
|
Reference in a new issue