refactor: update imports and type definitions in services
Some checks failed
CI / Get Changed Files (pull_request) Successful in 7s
CI / eslint (pull_request) Successful in 26s
CI / test-build (pull_request) Successful in 31s
CI / prettier (pull_request) Failing after 54s
CI / Checkstyle Main (pull_request) Successful in 1m57s

This commit is contained in:
Jan K9f 2025-04-02 16:20:37 +02:00
parent d3b7e7d5e7
commit e37dcecd3f
Signed by: jank
GPG key ID: B9F475106B20F144
4 changed files with 12 additions and 10 deletions

View file

@ -17,7 +17,7 @@ import {
import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms'; import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
import { loadStripe, Stripe } from '@stripe/stripe-js'; import { loadStripe, Stripe } from '@stripe/stripe-js';
import { debounceTime } from 'rxjs'; import { debounceTime } from 'rxjs';
import { NgIf } from '@angular/common'; import { CommonModule } from '@angular/common';
import gsap from 'gsap'; import gsap from 'gsap';
import { DepositService } from '@service/deposit.service'; import { DepositService } from '@service/deposit.service';
import { environment } from '@environments/environment'; import { environment } from '@environments/environment';
@ -26,7 +26,7 @@ import { ModalAnimationService } from '@shared/services/modal-animation.service'
@Component({ @Component({
selector: 'app-deposit', selector: 'app-deposit',
standalone: true, standalone: true,
imports: [ReactiveFormsModule, NgIf], imports: [ReactiveFormsModule, CommonModule],
templateUrl: './deposit.component.html', templateUrl: './deposit.component.html',
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
}) })

View file

@ -1,6 +1,7 @@
import { ChangeDetectionStrategy, Component, inject, signal, OnInit } from '@angular/core'; import { ChangeDetectionStrategy, Component, inject, signal, OnInit } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
// Importing components used in templates
import { PlayingCardComponent } from './components/playing-card/playing-card.component'; import { PlayingCardComponent } from './components/playing-card/playing-card.component';
import { DealerHandComponent } from './components/dealer-hand/dealer-hand.component'; import { DealerHandComponent } from './components/dealer-hand/dealer-hand.component';
import { PlayerHandComponent } from './components/player-hand/player-hand.component'; import { PlayerHandComponent } from './components/player-hand/player-hand.component';

View file

@ -158,8 +158,8 @@ export class AuthService {
} }
} }
private processUserProfile(profile: Record<string, unknown>) { private processUserProfile(profile: unknown) {
this.fromUserProfile(profile).subscribe({ this.fromUserProfile(profile as Record<string, unknown>).subscribe({
next: (user) => { next: (user) => {
console.log('User created/retrieved from backend:', user); console.log('User created/retrieved from backend:', user);
this.user = user; this.user = user;
@ -225,7 +225,7 @@ export class AuthService {
return this.oauthService.hasValidAccessToken(); return this.oauthService.hasValidAccessToken();
} }
private fromUserProfile(profile: object) { private fromUserProfile(profile: Record<string, unknown>) {
return this.userService.getOrCreateUser(profile); return this.userService.getOrCreateUser(profile);
} }

View file

@ -47,12 +47,13 @@ export class UserService {
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
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 = const username =
profile.info?.preferred_username || info?.['preferred_username'] as string ||
profile['preferred_username'] || profile['preferred_username'] as string ||
profile['email'] || profile['email'] as string ||
profile['name']; profile['name'] as string;
if (!id || !username) { if (!id || !username) {
console.error('Could not extract user ID or username from profile', profile); console.error('Could not extract user ID or username from profile', profile);