From 69288a4540287308c7c4ee81824e3d6c8c26c227 Mon Sep 17 00:00:00 2001
From: Helmut Hutzler <helmut.hutzler@th-nuernberg.de>
Date: Wed, 14 Dec 2022 15:18:52 +0100
Subject: [PATCH] Fixing Keycloak redirect problem in account-self- deletion
 feature

---
 .../account-self-deletion.component.ts           | 16 ++++++----------
 src/environments/environment.prod.ts             |  5 ++---
 src/environments/environment.ts                  |  8 +++-----
 3 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/src/app/account-self-deletion/account-self-deletion.component.ts b/src/app/account-self-deletion/account-self-deletion.component.ts
index 758cfe0..277d94e 100644
--- a/src/app/account-self-deletion/account-self-deletion.component.ts
+++ b/src/app/account-self-deletion/account-self-deletion.component.ts
@@ -11,7 +11,7 @@ import {environment} from "../../environments/environment";
 })
 export class AccountSelfDeletionComponent implements OnInit {
   private logHeader = '';
-  private redirectLoction  = '';
+  private redirectLocation  = '';
   constructor(public accountService: AccountService,
               public messageService: MessageService,
     ) {}
@@ -25,16 +25,12 @@ export class AccountSelfDeletionComponent implements OnInit {
                if we just use /auth this will fails as we get  redirect to http://localhaost:4200:/auth
         To overcome this we have defined environment.proxyKeycloakURL
      */
-    if (!environment.production) {
-      this.redirectLoction = environment.proxyKeycloakURL;
-    }
-    else {
-      this.redirectLoction = environment.keycloakURL;
-    }
-    this.redirectLoction = this.redirectLoction + 'realms/RBAC/account/#/personal-info';
-    console.warn('Now running Page Redirect to : ' + this.redirectLoction);
+    this.redirectLocation = environment.realKeycloakURL;
+
+    this.redirectLocation = this.redirectLocation + 'realms/RBAC/account/#/personal-info';
+    console.warn(this.logHeader + 'Running Page Redirect to : ' + this.redirectLocation);
     //window.location.href = "https://kube-master-h1.informatik.fh-nuernberg.de/auth/realms/RBAC/account/#/personal-info";
-    window.location.href = this.redirectLoction;
+    window.location.href = this.redirectLocation;
   }
 
 }
diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts
index 04d3a58..656e86e 100644
--- a/src/environments/environment.prod.ts
+++ b/src/environments/environment.prod.ts
@@ -2,10 +2,9 @@ declare const require: any;
 
 export const environment = {
   production: true,
-  //keycloakURL: 'https://kube-master-h1.informatik.fh-nuernberg.de/auth/',
-  //apiURL: 'https://kube-master-h1.informatik.fh-nuernberg.de/api',
+  // Only used for in account-self-deletion.component component for keycloak page redirect
+  realKeycloakURL: 'http://localhost:8280/auth/',
   keycloakURL: '/auth/',
-  proxyKeycloakURL: '/auth/',
   apiURL: '/api',
   appVersion: require('../../package.json').version
 };
diff --git a/src/environments/environment.ts b/src/environments/environment.ts
index f8058b4..90ce6e8 100644
--- a/src/environments/environment.ts
+++ b/src/environments/environment.ts
@@ -6,18 +6,16 @@ declare const require: any;
 
 export const environment = {
   production: false,
-   //  keycloakURL: 'http://localhost:8280/auth/'
+     // Only used for in account-self-deletion.component component for keycloak page redirect
+    realKeycloakURL: 'http://localhost:8280/auth/',
     keycloakURL: '/auth/',
-    // Only used for development in account-self-deletion.component component for page redirect
-    proxyKeycloakURL: 'https://kube-master-h1.informatik.fh-nuernberg.de/auth/',
-    //  apiURL: 'http://localhost:8080/api',
     apiURL: '/api',
     appVersion: require('../../package.json').version
 
 };
 
 /*
- * For easier debugging in development mode, you can import the following file
+ * For easier debugging in development mode, yu can import the following file
  * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
  *
  * This import should be commented out in production mode because it will have a negative impact
-- 
GitLab