Compare commits

..

20 commits

Author SHA1 Message Date
98668a3fb0
style: clean up import statements for consistency
Some checks failed
CI / Get Changed Files (pull_request) Successful in 8s
CI / Checkstyle Main (pull_request) Has been skipped
CI / Docker backend validation (pull_request) Successful in 12s
CI / oxlint (pull_request) Successful in 27s
CI / eslint (pull_request) Successful in 31s
CI / Docker frontend validation (pull_request) Successful in 44s
CI / prettier (pull_request) Failing after 27s
CI / test-build (pull_request) Successful in 34s
2025-05-07 17:31:04 +02:00
a622dbc7f4
feat(slots): add slot machine component with styling and logic 2025-05-07 17:31:04 +02:00
4a312dda35
Merge pull request 'fix: fix login/register' (!172) from bugfix/fix-login into main
All checks were successful
Release / Release (push) Successful in 1m19s
Release / Build Backend Image (push) Successful in 24s
Release / Build Frontend Image (push) Successful in 31s
Reviewed-on: #172
Reviewed-by: Jan-Marlon Leibl <jleibl@proton.me>
2025-05-07 15:30:27 +00:00
88c2f49b03
style(navbar): format import statements and arrow function
All checks were successful
CI / Get Changed Files (pull_request) Successful in 7s
CI / Checkstyle Main (pull_request) Has been skipped
CI / Docker backend validation (pull_request) Successful in 9s
CI / oxlint (pull_request) Successful in 24s
CI / Docker frontend validation (pull_request) Successful in 37s
CI / eslint (pull_request) Successful in 29s
CI / prettier (pull_request) Successful in 28s
CI / test-build (pull_request) Successful in 31s
2025-05-07 17:26:44 +02:00
db6bf4f199
refactor(auth.service): remove unused imports and variables
Some checks failed
CI / Get Changed Files (pull_request) Successful in 10s
CI / Checkstyle Main (pull_request) Has been skipped
CI / Docker backend validation (pull_request) Successful in 14s
CI / oxlint (pull_request) Successful in 26s
CI / eslint (pull_request) Successful in 34s
CI / Docker frontend validation (pull_request) Successful in 47s
CI / prettier (pull_request) Failing after 23s
CI / test-build (pull_request) Successful in 32s
2025-05-07 17:24:32 +02:00
ad77c76d14
fix: fix login/register
Some checks failed
CI / Get Changed Files (pull_request) Successful in 8s
CI / Checkstyle Main (pull_request) Has been skipped
CI / Docker backend validation (pull_request) Successful in 10s
CI / Docker frontend validation (pull_request) Successful in 36s
CI / oxlint (pull_request) Successful in 25s
CI / prettier (pull_request) Failing after 26s
CI / eslint (pull_request) Successful in 32s
CI / test-build (pull_request) Successful in 41s
2025-05-07 17:23:51 +02:00
62e7e0ec65
Merge pull request 'feat(auth): rewrite authentication to not use oauth manage users in app instead' (!163) from feature/authentication into main
All checks were successful
Release / Release (push) Successful in 1m3s
Release / Build Frontend Image (push) Successful in 28s
Release / Build Backend Image (push) Successful in 31s
Reviewed-on: #163
Reviewed-by: Jan-Marlon Leibl <jleibl@proton.me>
2025-05-07 14:28:49 +00:00
5a0d7b2313
chore: prettier
All checks were successful
CI / Get Changed Files (pull_request) Successful in 12s
CI / Docker backend validation (pull_request) Successful in 13s
CI / eslint (pull_request) Successful in 36s
CI / Docker frontend validation (pull_request) Successful in 53s
CI / Checkstyle Main (pull_request) Successful in 52s
CI / oxlint (pull_request) Successful in 24s
CI / prettier (pull_request) Successful in 26s
CI / test-build (pull_request) Successful in 43s
2025-05-07 16:26:21 +02:00
91e546226d
chore: shitty ahh rebase
Some checks failed
CI / Get Changed Files (pull_request) Successful in 10s
CI / Docker backend validation (pull_request) Successful in 10s
CI / oxlint (pull_request) Successful in 28s
CI / Docker frontend validation (pull_request) Successful in 43s
CI / eslint (pull_request) Successful in 34s
CI / Checkstyle Main (pull_request) Successful in 46s
CI / prettier (pull_request) Failing after 24s
CI / test-build (pull_request) Successful in 34s
2025-05-07 16:23:06 +02:00
84250969aa
feat(auth): add user refresh functionality in services
Some checks failed
CI / Get Changed Files (pull_request) Successful in 9s
CI / Docker backend validation (pull_request) Successful in 10s
CI / Docker frontend validation (pull_request) Failing after 36s
CI / oxlint (pull_request) Failing after 27s
CI / eslint (pull_request) Failing after 33s
CI / Checkstyle Main (pull_request) Successful in 46s
CI / prettier (pull_request) Failing after 23s
CI / test-build (pull_request) Failing after 31s
2025-05-07 15:39:39 +02:00
851cfe1bc8
refactor: remove unused parameters and improve formatting 2025-05-07 15:39:39 +02:00
1111c91407
feat(auth): update login and register components design 2025-05-07 15:39:39 +02:00
a178386355
style: clean up import statements for consistency 2025-05-07 15:39:39 +02:00
0cf2ea3438
refactor: clean up unused imports across controllers 2025-05-07 15:39:39 +02:00
8ba6d4e4d9
feat(auth): put login and register templates in files 2025-05-07 15:39:39 +02:00
b1e173f44b
refactor: remove redundant user not found message handling 2025-05-07 15:39:39 +02:00
29a53ea781
fix: fix stupid ahh bug where u get logged out when doing fucking anything stupid fucking http interceptor 2025-05-07 15:39:39 +02:00
3b95725d88
refactor: simplify user service and update routes 2025-05-07 15:39:38 +02:00
51540c930b
style: format code and improve readability 2025-05-07 15:39:11 +02:00
35d8fbaea0
feat: implement authentication with JWT and user management 2025-05-07 15:38:53 +02:00
3 changed files with 12 additions and 33 deletions

View file

@ -1,11 +1,4 @@
import {
ChangeDetectionStrategy,
Component,
EventEmitter,
inject,
Input,
Output,
} from '@angular/core';
import { ChangeDetectionStrategy, Component, EventEmitter, inject, Input, Output } from '@angular/core';
import { TransactionService } from '@service/transaction.service';
import { Observable } from 'rxjs';
import { AsyncPipe, CurrencyPipe, DatePipe, NgIf } from '@angular/common';

View file

@ -18,24 +18,21 @@ export class AuthService {
private authUrl = `${environment.apiUrl}/auth`;
private userUrl = `${environment.apiUrl}/users`;
private currentUserSubject: BehaviorSubject<User | null>;
public currentUser: Observable<User | null>;
userSubject: BehaviorSubject<User | null>;
constructor(
private http: HttpClient,
private router: Router
) {
this.currentUserSubject = new BehaviorSubject<User | null>(this.getUserFromStorage());
this.currentUser = this.currentUserSubject.asObservable();
this.userSubject = new BehaviorSubject<User | null>(this.getUserFromStorage());
// Check if token exists and load user data
if (this.getToken()) {
this.loadCurrentUser();
}
}
public get currentUserValue(): User | null {
return this.currentUserSubject.value;
return this.userSubject.value;
}
login(loginRequest: LoginRequest): Observable<AuthResponse> {
@ -54,7 +51,7 @@ export class AuthService {
logout(): void {
localStorage.removeItem(TOKEN_KEY);
localStorage.removeItem(USER_KEY);
this.currentUserSubject.next(null);
this.userSubject.next(null);
this.router.navigate(['/']);
}
@ -83,7 +80,7 @@ export class AuthService {
private setUser(user: User): void {
localStorage.setItem(USER_KEY, JSON.stringify(user));
this.currentUserSubject.next(user);
this.userSubject.next(user);
}
private getUserFromStorage(): User | null {

View file

@ -10,7 +10,6 @@ import { RouterModule } from '@angular/router';
import { AuthService } from '@service/auth.service';
import { Subscription } from 'rxjs';
import { AnimatedNumberComponent } from '@blackjack/components/animated-number/animated-number.component';
import { UserService } from '@service/user.service';
@Component({
selector: 'app-navbar',
@ -24,30 +23,20 @@ export class NavbarComponent implements OnInit, OnDestroy {
private authService: AuthService = inject(AuthService);
isLoggedIn = this.authService.isLoggedIn();
private userSubscription: Subscription | undefined;
private authSubscription: Subscription | undefined;
private authSubscription!: Subscription;
public balance = signal(0);
private userService = inject(UserService);
ngOnInit() {
// Subscribe to auth changes
this.authSubscription = this.authService.currentUser.subscribe((user) => {
this.isLoggedIn = !!user;
this.authSubscription = this.authService.userSubject.subscribe({
next: (user) => {
this.balance.set(user?.balance ?? 0);
console.log('Updated navbar balance:', user?.balance);
},
});
this.userService.refreshCurrentUser();
}
ngOnDestroy() {
if (this.userSubscription) {
this.userSubscription.unsubscribe();
}
if (this.authSubscription) {
this.authSubscription.unsubscribe();
}
}
logout() {
this.authService.logout();