This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new 90ee6b39 [Improve] need verify code when password error (#465)
90ee6b39 is described below
commit 90ee6b3904bb8216a714be48c7899bd4b7ad7a92
Author: VampireAchao <[email protected]>
AuthorDate: Thu Aug 1 16:57:50 2024 +0800
[Improve] need verify code when password error (#465)
* [Improve] show admin configureDataPermission
* [Improve] admin not show edit
* [Improve] need verify code when password error
---
src/models/login.js | 2 ++
src/routes/User/Login.js | 37 ++++++++++++++++++++++++++-----------
2 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/src/models/login.js b/src/models/login.js
index f4614f14..69afd8d0 100644
--- a/src/models/login.js
+++ b/src/models/login.js
@@ -30,7 +30,9 @@ export default {
effects: {
*login({ payload }, { call, put }) {
+ const { callback } = payload;
const response = yield call(queryLogin, payload);
+ yield call(callback, response);
// Login successfully
if (response.data) {
diff --git a/src/routes/User/Login.js b/src/routes/User/Login.js
index ce225b24..e751d938 100644
--- a/src/routes/User/Login.js
+++ b/src/routes/User/Login.js
@@ -58,20 +58,22 @@ export default class LoginPage extends Component {
constructor(props) {
super(props);
this.state = {
- VCode: "",
+ VCode: undefined,
codeError: true,
+ needCode: false,
};
this.ChildRef = React.createRef();
}
componentDidMount() {
- this.ChildRef.current.handleChange();
+ this.ChildRef.current?.handleChange();
}
handleSubmit = (err, values) => {
const { dispatch } = this.props;
+ const { needCode } = this.state;
if (!err) {
- if (values.verifyCode !== this.state.VCode) {
+ if (needCode && values.verifyCode !== this.state.VCode) {
this.setState({ codeError: false });
this.ChildRef.current.handleChange();
return;
@@ -95,6 +97,11 @@ export default class LoginPage extends Component {
type: "login/login",
payload: {
...values,
+ callback: (res) => {
+ if (res.code === 500) {
+ this.setState({ needCode: true });
+ }
+ },
},
});
}
@@ -130,20 +137,28 @@ export default class LoginPage extends Component {
render() {
const { submitting } = this.props;
+ const { needCode } = this.state;
return (
<div className={styles.main}>
<Login onSubmit={this.handleSubmit}>
<div>
<UserName name="userName" placeholder="Account" />
<Password name="password" placeholder="Password" />
- <div className={styles.verify}>
- <VerifyCode name="verifyCode" placeholder="Verification Code" />
- {this.codeError()}
- </div>
- <LoginCode
- onRef={this.ChildRef}
- ChildGetCode={(code) => this.getCode(code)}
- />
+ {needCode && (
+ <>
+ <div className={styles.verify}>
+ <VerifyCode
+ name="verifyCode"
+ placeholder="Verification Code"
+ />
+ {this.codeError()}
+ </div>
+ <LoginCode
+ onRef={this.ChildRef}
+ ChildGetCode={(code) => this.getCode(code)}
+ />
+ </>
+ )}
</div>
<Submit loading={submitting}>Login</Submit>
</Login>