From 2c98b0954ac5c50ea9c77e9ee780e3dee4fcdad8 Mon Sep 17 00:00:00 2001 From: Yoshie Muranaka Date: Mon, 22 Jun 2020 13:28:09 -0700 Subject: Add check if password change required at Login After successfully authenticating on the Login page, check /redfish/v1/AccountService/Accounts/${username} endpoint for the PasswordChangeRequired property to see whether or not the password is expired. If the password is expired, then navigate to the Change password page, if the password isn't expired navigate to the Overview page. After successfully changing an expired password, navigate to the Overview page. Signed-off-by: Yoshie Muranaka Change-Id: I32de5f71bcfcbe4099c2953a31c05ba0ebe670bc --- src/locales/en-US.json | 1 + src/router/index.js | 3 +- .../modules/Authentication/AuthenticanStore.js | 6 ++++ src/views/ChangePassword/ChangePassword.vue | 35 +++++++++++++++------- src/views/Login/Login.vue | 12 +++++++- 5 files changed, 44 insertions(+), 13 deletions(-) diff --git a/src/locales/en-US.json b/src/locales/en-US.json index 76d9aaf1..02600f4c 100644 --- a/src/locales/en-US.json +++ b/src/locales/en-US.json @@ -118,6 +118,7 @@ "pageChangePassword": { "changePassword": "Change password", "changePasswordAlertMessage": "The password is expired and must be changed.", + "changePasswordError": "There was an error changing the password.", "confirmNewPassword": "Confirm new password", "goBack": "Go back", "newPassword": "New password", diff --git a/src/router/index.js b/src/router/index.js index 8fa42c89..0da37fa8 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -164,7 +164,8 @@ const routes = [ name: 'change-password', component: () => import('@/views/ChangePassword'), meta: { - title: 'appPageTitle.changePassword' + title: 'appPageTitle.changePassword', + requiresAuth: true } } ] diff --git a/src/store/modules/Authentication/AuthenticanStore.js b/src/store/modules/Authentication/AuthenticanStore.js index 407c2b57..4afb11de 100644 --- a/src/store/modules/Authentication/AuthenticanStore.js +++ b/src/store/modules/Authentication/AuthenticanStore.js @@ -43,6 +43,12 @@ const AuthenticationStore = { .then(() => commit('logout')) .then(() => router.go('/login')) .catch(error => console.log(error)); + }, + async checkPasswordChangeRequired(_, username) { + return await api + .get(`/redfish/v1/AccountService/Accounts/${username}`) + .then(({ data: { PasswordChangeRequired } }) => PasswordChangeRequired) + .catch(error => console.log(error)); } } }; diff --git a/src/views/ChangePassword/ChangePassword.vue b/src/views/ChangePassword/ChangePassword.vue index 0b1b6897..b2edcd47 100644 --- a/src/views/ChangePassword/ChangePassword.vue +++ b/src/views/ChangePassword/ChangePassword.vue @@ -1,7 +1,10 @@