VerificationCode(ClickWordCaptchaInput input);
}
diff --git a/Api/Ewide.Core/applicationconfig.json b/Api/Ewide.Core/applicationconfig.json
index 9008b08..3ae16a9 100644
--- a/Api/Ewide.Core/applicationconfig.json
+++ b/Api/Ewide.Core/applicationconfig.json
@@ -102,5 +102,10 @@
"sysNotice:unread",
"sysNotice:detail"
]
+ },
+
+ "SimplePassword": {
+ "Pattern": "(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[^a-zA-Z0-9]){8,}",
+ "Descriptions": "密码中必须包含大小字母、数字、特称字符,至少8个字符"
}
}
\ No newline at end of file
diff --git a/web-react/src/common/api/requests/sys/loginManage.js b/web-react/src/common/api/requests/sys/loginManage.js
index 8d969e3..216a8e4 100644
--- a/web-react/src/common/api/requests/sys/loginManage.js
+++ b/web-react/src/common/api/requests/sys/loginManage.js
@@ -3,6 +3,10 @@ const urls = {
* 登录
*/
login: ['/login', 'post'],
+ /**
+ * 登录时修改密码
+ */
+ loginPass: ['/loginPass', 'post'],
/**
* 登出
*/
diff --git a/web-react/src/views/login/index.jsx b/web-react/src/views/login/index.jsx
index d7290aa..ef7dfa2 100644
--- a/web-react/src/views/login/index.jsx
+++ b/web-react/src/views/login/index.jsx
@@ -1,5 +1,5 @@
import React, { Component } from 'react'
-import { Button, Form, Input, message as Message } from 'antd'
+import { Alert, Button, Form, Input, message as Message, Modal } from 'antd'
import Container from 'components/container'
import { encryptByRSA } from 'util/rsa'
import { RSA_PUBLIC_KEY } from 'util/global'
@@ -14,6 +14,10 @@ export default class index extends Component {
focusPassword: false,
btnDisabled: true,
+
+ pattern: '',
+ descriptions: '',
+ visible: false,
}
backgroundImage = require(`assets/image/login-bg-0${Math.floor(Math.random() * 4)}.jpg`)
@@ -33,9 +37,19 @@ export default class index extends Component {
api.login({ account, password })
.then(({ success, data, message }) => {
if (success) {
- token.value = data
- Message.success('登录成功')
- this.props.history.replace('/')
+ const { passed, pattern, descriptions, token } = data
+ // 简单密码需要更改
+ if (!passed) {
+ this.setState({
+ visible: true,
+ loading: false,
+ btnDisabled: true,
+ pattern,
+ descriptions,
+ })
+ } else {
+ this.onLoginSuccess(token)
+ }
} else {
this.setState({ loading: false })
Message.error(message)
@@ -49,8 +63,52 @@ export default class index extends Component {
})
}
+ onLoginPass = values => {
+ this.setState({ loading: true })
+ const account = this.form.current.getFieldValue('account')
+ let { password, newPassword } = values
+ password = encryptByRSA(password, RSA_PUBLIC_KEY)
+ newPassword = encryptByRSA(newPassword, RSA_PUBLIC_KEY)
+ const confirm = newPassword // 前端验证两次密码即可.不需要加密
+
+ api.loginPass({ account, password, newPassword, confirm })
+ .then(({ success, data, message }) => {
+ if (success) {
+ const { passed, pattern, descriptions, token } = data
+ // 简单密码需要更改
+ if (!passed) {
+ this.setState({
+ visible: true,
+ loading: false,
+ btnDisabled: true,
+ pattern,
+ descriptions,
+ })
+ } else {
+ this.onLoginSuccess(token)
+ }
+ } else {
+ this.setState({ loading: false })
+ Message.error(message)
+ }
+ })
+ .catch(({ message }) => {
+ if (typeof message === 'object' && message[0]) {
+ Message.error(message[0].messages[0])
+ }
+ this.setState({ loading: false })
+ })
+ }
+
+ onLoginSuccess(jwtToken) {
+ token.value = jwtToken
+ Message.success('登录成功')
+ this.props.history.replace('/')
+ }
+
render() {
- const { loading, focusUser, focusPassword, btnDisabled } = this.state
+ const { loading, focusUser, focusPassword, btnDisabled, visible, pattern, descriptions } =
+ this.state
return (
@@ -121,6 +179,54 @@ export default class index extends Component {
+
+
+
+
+
+
+
+
)
}