Authored by 陈峰

commit

... ... @@ -28,6 +28,8 @@ export default {
const validatePass = (rule, value, callback) => {
if (value === '') {
return callback(new Error('请输入密码'));
} else if (!/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_])[a-zA-Z\d\W_]{8,}$/.test(value)) {
return callback(new Error('密码长度必须大于八位,且包含大写字母,小写字母,数字和特殊字符'));
} else {
if (this.formInline.passwdCheck !== '') {
// 对第二个密码框单独验证
... ... @@ -54,10 +56,10 @@ export default {
},
ruleInline: {
passwd: [
{ validator: validatePass, trigger: 'blur' }
{ validator: validatePass, trigger: 'change' }
],
passwdCheck: [
{ validator: validatePassCheck, trigger: 'blur' }
{ validator: validatePassCheck, trigger: 'change' }
]
}
};
... ... @@ -71,7 +73,7 @@ export default {
if (valid) {
this.update(this.formInline.passwdCheck);
} else {
this.$Message.error('表单验证失败!');
this.$Message.error('请按照规则输入密码!');
}
});
},
... ... @@ -79,15 +81,13 @@ export default {
this.loading = true;
this.UserService.update({
account: '123',
password: passwdCheck
}).then(ret => {
if (ret.code === 200) {
this.loading = false;
if (ret.code === 200) {
Vue.$store.remove('needUpdate');
this.$router.push('/');
} else {
this.loading = false;
this.$Message.error(ret.message);
}
});
... ... @@ -98,6 +98,6 @@ export default {
<style lang="scss">
.password {
width: 400px;
width: 500px;
}
</style>
... ...
... ... @@ -10,13 +10,7 @@ class UserService extends Service {
});
}
update(params) {
return this.post('/erp/update', params).then(ret => {
if (ret.code === 200) {
return this.get('/completeUpdate');
} else {
return ret;
}
});
return this.post('/updatePwd', params);
}
purviews() {
return this.post('/erp/getPurview', {
... ...
... ... @@ -26,6 +26,6 @@ router.post('/import', before, auth, middleware(ImportController, 'import'));
router.post('/config', middleware(UserController, 'config'));
router.get('/captcha.jpg', middleware(CaptchaController, 'captcha'));
router.get('/geeCaptcha', middleware(GeeCaptchaController, 'captcha'));
router.get('/completeUpdate', middleware(UserController, 'completeUpdate'));
router.post('/updatePwd', middleware(UserController, 'updatePwd'));
module.exports = router;
... ...
... ... @@ -72,18 +72,39 @@ class UserController extends Context {
}).catch(next);
}
completeUpdate(req, res) {
updatePwd(req, res) {
if (!req.user.uid) {
return res.status(401).json({
code: 401,
message: '抱歉,您暂未登录!',
data: {
refer: '/login'
}
});
}
if (!req.body.password) {
return res.json({
code: 400,
message: '请输入密码'
});
}
return this.userService.updatePwd(req.user.uid, req.body.password).then(result => {
if (result.code !== 200) {
return res.json(result);
}
delete req.session.needUpdate;
return res.json({
code: 200,
data: '密码修改成功'
});
});
}
logout(req, res) {
delete req.session.USER;
delete req.session.LOGIN_UID;
delete req.session.CURRENT_SHOP;
delete req.session.needUpdate;
res.clearCookie('PHPSESSID', {
domain: '.yohobuy.com'
});
... ...
... ... @@ -14,17 +14,6 @@ module.exports = (req, res, next) => {
}
});
}
if (req.session.needUpdate &&
req.path !== '/Api/erp/getPurview' &&
req.path !== '/Api/erp/update') {
return res.status(403).json({
code: 403,
message: '抱歉,您暂未修改密码!',
data: {
refer: '/password'
}
});
}
next();
};
... ...
... ... @@ -31,6 +31,13 @@ class UserService extends Context {
return userInfo.data;
});
}
updatePwd(pid, password) {
return this.api.post(config.apiDomain.erp.update, {
pid,
password,
});
}
shopLogin(account, password) {
return rp.get({
... ...