From e1bb591a38ab1eae211814757a15556e2b346bd7 Mon Sep 17 00:00:00 2001 From: Marek Lesko Date: Thu, 30 Oct 2025 16:51:21 +0000 Subject: [PATCH] feat: remove unused branding component from callback, update authentication service to handle missing issuer in configuration --- .../callback/callback.component.html | 27 ------------------- .../callback/callback.component.ts | 3 +-- .../side-logout/side-logout.component.html | 8 +++--- .../app/services/authentication.service.ts | 27 ++++++++++--------- 4 files changed, 20 insertions(+), 45 deletions(-) diff --git a/Web/src/app/pages/authentication/callback/callback.component.html b/Web/src/app/pages/authentication/callback/callback.component.html index 02eb282..e69de29 100755 --- a/Web/src/app/pages/authentication/callback/callback.component.html +++ b/Web/src/app/pages/authentication/callback/callback.component.html @@ -1,27 +0,0 @@ -
-
-
-
- - -
- login -
-
-
-
-
-
-

Authentikácia úspešná!

- @if(!profile) { - Načítavam Vaše údaje... - } - @else{ - {{profile.email}} - profile picture - } -
-
-
-
-
\ No newline at end of file diff --git a/Web/src/app/pages/authentication/callback/callback.component.ts b/Web/src/app/pages/authentication/callback/callback.component.ts index b3624bb..bdf99ff 100755 --- a/Web/src/app/pages/authentication/callback/callback.component.ts +++ b/Web/src/app/pages/authentication/callback/callback.component.ts @@ -2,13 +2,12 @@ import { Component } from '@angular/core'; import { Router, RouterModule } from '@angular/router'; import { CoreService } from '../../../services/core.service'; import { MaterialModule } from '../../../material.module'; -import { BrandingComponent } from '../../../layouts/full/vertical/sidebar/branding.component'; import { AuthenticationService } from '../../../services/authentication.service'; import { NgScrollbarModule } from "ngx-scrollbar"; @Component({ selector: 'app-callback', - imports: [RouterModule, MaterialModule, BrandingComponent, NgScrollbarModule], + imports: [RouterModule, MaterialModule, NgScrollbarModule], templateUrl: './callback.component.html', }) export class CallbackComponent { diff --git a/Web/src/app/pages/authentication/side-logout/side-logout.component.html b/Web/src/app/pages/authentication/side-logout/side-logout.component.html index 7ccd6d4..dfb7ecb 100644 --- a/Web/src/app/pages/authentication/side-logout/side-logout.component.html +++ b/Web/src/app/pages/authentication/side-logout/side-logout.component.html @@ -5,7 +5,7 @@
- login + prihlásenie
@@ -13,14 +13,14 @@
-

Signed out

- You have beens successfully logged out. +

Odhlásenie

+ Úspešne ste sa odhlásili.
- Prihlásenie + Prihlásiť sa
diff --git a/Web/src/app/services/authentication.service.ts b/Web/src/app/services/authentication.service.ts index a9be0c6..8bf4c06 100644 --- a/Web/src/app/services/authentication.service.ts +++ b/Web/src/app/services/authentication.service.ts @@ -1,4 +1,5 @@ import { Injectable } from '@angular/core'; +import { Router } from '@angular/router'; import { AuthConfig, OAuthService } from 'angular-oauth2-oidc'; const CONFIG_KEY = 'oauth_config_v1'; @@ -17,7 +18,7 @@ export class AuthenticationService { public profile: any = null; - constructor(private oauthService: OAuthService) { } + constructor(private oauthService: OAuthService, private router: Router) { } saveConfig(cfg: Partial) { try { @@ -52,7 +53,7 @@ export class AuthenticationService { // Restore configuration from storage and apply to OAuthService restoreConfiguration(): boolean { const cfg = this.loadConfig() ?? this.config; - if (!cfg) return false; + if (!cfg.issuer) return false; this.oauthService.configure(cfg); return true; } @@ -70,16 +71,18 @@ export class AuthenticationService { // Call this on the callback route to process the redirect and obtain tokens + profile handleCallback(): Promise { - this.restoreConfiguration(); - // Ensure discovery document loaded, then process code flow, then load profile - return this.oauthService - .loadDiscoveryDocumentAndTryLogin() - .then((isLoggedIn: boolean) => { - if (!isLoggedIn && !this.oauthService.hasValidAccessToken()) { - return Promise.reject('No valid token after callback'); - } - return this.loadUserProfile(); - }); + if (this.restoreConfiguration()) + // Ensure discovery document loaded, then process code flow, then load profile + return this.oauthService + .loadDiscoveryDocumentAndTryLogin() + .then((isLoggedIn: boolean) => { + if (!isLoggedIn && !this.oauthService.hasValidAccessToken()) { + return Promise.reject('No valid token after callback'); + } + return this.loadUserProfile(); + }); + else + return this.router.navigate(['/authentication/login']); } loadUserProfile(): Promise {