From 54ecfa90129989239aa66ab087cb1a8afe607735 Mon Sep 17 00:00:00 2001 From: Tiago Melo Date: Fri, 22 May 2020 10:58:39 +0000 Subject: [PATCH] mgr/dashboard: Fix redirect after changing password After the changes made to subscriptions, redirecting to the dummy logout page no longer does anything. So we removed the logout route and now redirect directly to the login page. Fixes: https://tracker.ceph.com/issues/45651 Signed-off-by: Tiago Melo --- .../mgr/dashboard/frontend/src/app/app-routing.module.ts | 3 +-- .../user-password-form/user-password-form.component.spec.ts | 2 +- .../auth/user-password-form/user-password-form.component.ts | 6 +----- .../frontend/src/app/shared/api/auth.service.spec.ts | 2 +- .../dashboard/frontend/src/app/shared/api/auth.service.ts | 2 +- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts index 3e98b5268b4..e4ef9753c7e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts @@ -300,8 +300,7 @@ const routes: Routes = [ path: 'login-change-password', component: LoginPasswordFormComponent, canActivate: [NoSsoGuardService] - }, - { path: 'logout', children: [] } + } ] }, { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-password-form/user-password-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-password-form/user-password-form.component.spec.ts index a53f4451cb3..44e9201381b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-password-form/user-password-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-password-form/user-password-form.component.spec.ts @@ -79,6 +79,6 @@ describe('UserPasswordFormComponent', () => { }); request.flush({}); expect(component.onPasswordChange).toHaveBeenCalled(); - expect(router.navigate).toHaveBeenCalledWith(['/logout']); + expect(router.navigate).toHaveBeenCalledWith(['/login']); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-password-form/user-password-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-password-form/user-password-form.component.ts index e77d9d86bf6..cf08a134fb3 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-password-form/user-password-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-password-form/user-password-form.component.ts @@ -116,10 +116,6 @@ export class UserPasswordFormComponent { */ onPasswordChange() { this.notificationService.show(NotificationType.success, this.i18n('Updated user password"')); - // Theoretically it is not necessary to navigate to '/logout' because - // the auth token gets invalid after changing the password in the - // backend, thus the user would be automatically logged out after the - // next periodically API request is executed. - this.router.navigate(['/logout']); + this.router.navigate(['/login']); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/auth.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/auth.service.spec.ts index b88e8d85320..986907d53dc 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/auth.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/auth.service.spec.ts @@ -11,7 +11,7 @@ describe('AuthService', () => { let service: AuthService; let httpTesting: HttpTestingController; - const routes: Routes = [{ path: 'logout', children: [] }]; + const routes: Routes = [{ path: 'login', children: [] }]; configureTestBed({ providers: [AuthService, AuthStorageService], diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/auth.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/auth.service.ts index c6229377f90..c8ac216f78b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/auth.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/auth.service.ts @@ -41,7 +41,7 @@ export class AuthService { logout(callback: Function = null) { return this.http.post('api/auth/logout', null).subscribe((resp: any) => { - this.router.navigate(['/logout'], { skipLocationChange: true }); + this.router.navigate(['/login'], { skipLocationChange: true }); this.authStorageService.remove(); if (callback) { callback(); -- 2.47.3