From df2ee7f4bd65facca90926dd299f94e50a6a7ae6 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 (cherry picked from commit 54ecfa90129989239aa66ab087cb1a8afe607735) --- .../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 3a4646ac4bb2..f046d9c115a3 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 @@ -298,8 +298,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 3ac5f040fb09..31a7d7f971c7 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 @@ -82,6 +82,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 e77d9d86bf6f..cf08a134fb33 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 6a2e63d7b419..1dffaf04a77b 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 c6229377f906..c8ac216f78b9 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