Skip to content
This repository was archived by the owner on May 12, 2020. It is now read-only.

Commit 11f6df3

Browse files
committed
fix(login): correct multiple login error fix #11
问题描述: 在当前用户未注销的情况下,跳转 /login 登陆页时,即使用户密码错误,亦会使用之前未登出的用户的信息 本质: 在 login action 中包含一个 catch 函数,其本身返回一个 resolved Promise 实例,那么此时的 login action 将始终返回一个 resolved Promise 实例
1 parent 80baa1c commit 11f6df3

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/pages/Login/index.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ export default {
6464
methods: {
6565
onSubmit () {
6666
this.switchLoading(true)
67-
this.$refs.login.validate()
67+
this.$refs.login
68+
.validate()
6869
.then(valid => ({
6970
...this.userInfo,
7071
vm: this
7172
}))
7273
// This action has included routes replacement
7374
// dispatch() will return a Promise instance
7475
.then(payload => this.$store.dispatch('login/userLogin', payload))
75-
.then(() => this.$router.replace('/'))
7676
.catch(e => console.error('[Login form]: validate failed !'))
7777
.finally(() => this.switchLoading(false))
7878
},
@@ -93,7 +93,7 @@ export default {
9393
}
9494
9595
.login {
96-
background-image: url('~./img/animation.gif');
96+
background-image: url("~./img/animation.gif");
9797
background-repeat: no-repeat;
9898
background-position: center center;
9999

src/store/modules/login/actions.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { userLogin, fetchUserAccess } from 'API'
22
import types from './mutations/types'
3+
import router from 'ROUTER'
34

45
export default {
56
userLogin ({ commit }, { username, password, vm }) {
@@ -15,6 +16,7 @@ export default {
1516
userId: user_id
1617
})
1718
commit(types.SET_ACCESS_TOKEN, access_token)
19+
router.replace('/')
1820
})
1921
.catch(e => {
2022
if (e.code === 5000) {

0 commit comments

Comments
 (0)