4141 type =" primary"
4242 size =" large"
4343 block
44- @click =" handleLogout "
44+ @click =" redirectToLogin() "
4545 style =" margin-top : 20px ;"
4646 >
4747 {{ $t('label.login') }}
9595 </a-form-item >
9696
9797 <div class =" actions" >
98- <a @click =" handleLogout " >{{ $t('label.logout') }}</a >
98+ <a @click =" logoutAndRedirectToLogin() " >{{ $t('label.logout') }}</a >
9999 </div >
100100 </a-form >
101101 </a-spin >
@@ -167,7 +167,8 @@ export default {
167167 currentpassword: values .currentpassword
168168 }
169169 postAPI (' updateUser' , params).then (() => {
170- this .$message .success (this .$t (' message.please.login.new.password' ))
170+ this .$localStorage .remove (PASSWORD_CHANGE_REQUIRED )
171+ this .handleLogout ()
171172 this .isSubmitted = true
172173 }).catch (error => {
173174 console .error (error)
@@ -187,30 +188,19 @@ export default {
187188 } finally {
188189 Cookies .remove (' userid' )
189190 Cookies .remove (' token' )
190- this .$localStorage .remove (PASSWORD_CHANGE_REQUIRED )
191- this .$router .replace ({ path: ' /user/login' })
192191 }
193192 },
194- async isPasswordChangeRequired () {
195- try {
196- this .loading = true
197- const user = await this .getUserInfo ()
198- if (user && ! user .passwordchangerequired ) {
199- this .isSubmitted = true
200- }
201- } catch (e) {
202- console .error (' Failed to resolve user info:' , e)
203- } finally {
204- this .loading = false
205- }
193+ redirectToLogin () {
194+ this .$router .replace (' /user/login' )
206195 },
207- async getUserInfo () {
208- const userInfo = this .$store .getters .userInfo
209- if (userInfo && userInfo .id ) {
210- return userInfo
211- }
212- await this .$store .dispatch (' GetInfo' )
213- return this .$store .getters .userInfo
196+ logoutAndRedirectToLogin () {
197+ this .handleLogout ().then (() => {
198+ this .redirectToLogin ()
199+ })
200+ },
201+ async isPasswordChangeRequired () {
202+ const passwordChangeRequired = this .$localStorage .get (PASSWORD_CHANGE_REQUIRED )
203+ this .isSubmitted = ! passwordChangeRequired
214204 }
215205 }
216206}
0 commit comments