From aaa8679353dbc0c75209fdf1ac9e4308d67872b8 Mon Sep 17 00:00:00 2001
From: Sebastian-Ion TINCU <Sebastian-Ion.TINCU@ext.ec.europa.eu>
Date: Mon, 7 Oct 2024 15:34:42 +0200
Subject: [PATCH] EDELIVERY-13873 Internationalization User Role Translation is
 not Working Properly

Manually set the language upon logging in instead of relying on the asynchronous notification.
---
 smp-angular/src/app/login/login.component.ts     | 5 -----
 smp-angular/src/app/security/security.service.ts | 1 +
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/smp-angular/src/app/login/login.component.ts b/smp-angular/src/app/login/login.component.ts
index 5a5ce8703..4abeb0c61 100644
--- a/smp-angular/src/app/login/login.component.ts
+++ b/smp-angular/src/app/login/login.component.ts
@@ -40,8 +40,6 @@ export class LoginComponent implements OnInit, OnDestroy {
   loading = false;
   returnUrl: string;
   sub: Subscription;
-  localeSub: Subscription;
-
 
   constructor(private route: ActivatedRoute,
               private router: Router,
@@ -91,8 +89,6 @@ export class LoginComponent implements OnInit, OnDestroy {
         }
       });
 
-    this.localeSub = this.securityEventService.onLoginSuccessEvent().subscribe(user => user && this.translateService.use(user.smpLocale));
-
     this.securityEventService.onLoginErrorEvent().subscribe(
       async error => {
         let message;
@@ -176,7 +172,6 @@ export class LoginComponent implements OnInit, OnDestroy {
 
   ngOnDestroy(): void {
     this.sub.unsubscribe();
-    this.localeSub.unsubscribe();
   }
 
   isUserAuthSSOEnabled(): boolean {
diff --git a/smp-angular/src/app/security/security.service.ts b/smp-angular/src/app/security/security.service.ts
index b1e82dc40..c77e2e755 100644
--- a/smp-angular/src/app/security/security.service.ts
+++ b/smp-angular/src/app/security/security.service.ts
@@ -50,6 +50,7 @@ export class SecurityService {
       .subscribe({
         next: (response: User) => {
           this.updateUserDetails(response);
+          this.translateService.use(response?.smpLocale);
           this.securityEventService.notifyLoginSuccessEvent(response);
         },
         error: (error: any) => {
-- 
GitLab