feat:去掉注册时的验证码要求

This commit is contained in:
fanxb 2020-02-02 00:30:54 +08:00
parent 9cc1b83357
commit 1f430c3b48
2 changed files with 75 additions and 33 deletions

View File

@ -81,15 +81,6 @@ public class UserService {
* @date 2019/7/6 11:30 * @date 2019/7/6 11:30
*/ */
public void register(RegisterBody body) { public void register(RegisterBody body) {
String codeKey = Constant.authCodeKey(body.getEmail());
String realCode = RedisUtil.get(codeKey, String.class);
if (Constant.isDev) {
realCode = "123456";
}
if (StringUtil.isEmpty(realCode) || (!realCode.equals(body.getAuthCode()))) {
throw new FormDataException("验证码错误");
}
RedisUtil.delete(codeKey);
User user = userDao.selectByUsernameOrEmail(body.getUsername(), body.getEmail()); User user = userDao.selectByUsernameOrEmail(body.getUsername(), body.getEmail());
if (user != null) { if (user != null) {
if (user.getUsername().equals(body.getUsername())) { if (user.getUsername().equals(body.getUsername())) {

View File

@ -1,7 +1,11 @@
import React from "react"; import React from "react";
import IconFont from "../../../components/IconFont"; import IconFont from "../../../components/IconFont";
import { Button, Input, message } from "antd"; import { Button, Input, message } from "antd";
import { LoginLayout, REGISTER_TYPE, RESET_PASSWORD_TYPE } from "../../../layout/LoginLayout"; import {
LoginLayout,
REGISTER_TYPE,
RESET_PASSWORD_TYPE
} from "../../../layout/LoginLayout";
import styles from "./index.module.less"; import styles from "./index.module.less";
import axios from "../../../util/httpUtil"; import axios from "../../../util/httpUtil";
@ -109,16 +113,28 @@ export default class Register extends React.Component {
* 提交表单 * 提交表单
*/ */
submit = () => { submit = () => {
const { current, username, email, password, repassword, authCode } = this.state; const {
current,
username,
email,
password,
repassword,
authCode
} = this.state;
let form = { username, email, password, authCode }; let form = { username, email, password, authCode };
if (current === REGISTER_TYPE && !this.checkParam("username", username)) { if (current === REGISTER_TYPE && !this.checkParam("username", username)) {
return; return;
} }
if (
current === RESET_PASSWORD_TYPE &&
!this.checkParam("authCode", authCode)
) {
return;
}
const isOk = const isOk =
this.checkParam("email", email) && this.checkParam("email", email) &&
this.checkParam("password", password) && this.checkParam("password", password) &&
this.checkParam("repassword", repassword) && this.checkParam("repassword", repassword);
this.checkParam("authCode", authCode);
if (!isOk) { if (!isOk) {
return; return;
} }
@ -146,7 +162,18 @@ export default class Register extends React.Component {
}; };
render() { render() {
const { current, username, email, password, repassword, authCode, authCodeText, isCountDown, errorText, isLoading } = this.state; const {
current,
username,
email,
password,
repassword,
authCode,
authCodeText,
isCountDown,
errorText,
isLoading
} = this.state;
return ( return (
<LoginLayout type={current}> <LoginLayout type={current}>
<div className={styles.main}> <div className={styles.main}>
@ -158,7 +185,9 @@ export default class Register extends React.Component {
name="username" name="username"
value={username} value={username}
onChange={this.changeData} onChange={this.changeData}
addonBefore={<IconFont type="icon-person" style={{ fontSize: "0.3rem" }} />} addonBefore={
<IconFont type="icon-person" style={{ fontSize: "0.3rem" }} />
}
placeholder="用户名" placeholder="用户名"
/> />
) : null} ) : null}
@ -168,7 +197,9 @@ export default class Register extends React.Component {
name="email" name="email"
value={email} value={email}
onChange={this.changeData} onChange={this.changeData}
addonBefore={<IconFont type="icon-mail" style={{ fontSize: "0.3rem" }} />} addonBefore={
<IconFont type="icon-mail" style={{ fontSize: "0.3rem" }} />
}
placeholder="邮箱" placeholder="邮箱"
/> />
<Input <Input
@ -177,7 +208,9 @@ export default class Register extends React.Component {
name="password" name="password"
value={password} value={password}
onChange={this.changeData} onChange={this.changeData}
addonBefore={<IconFont type="icon-password" style={{ fontSize: "0.3rem" }} />} addonBefore={
<IconFont type="icon-password" style={{ fontSize: "0.3rem" }} />
}
placeholder="密码" placeholder="密码"
/> />
<Input <Input
@ -186,24 +219,42 @@ export default class Register extends React.Component {
name="repassword" name="repassword"
value={repassword} value={repassword}
onChange={this.changeData} onChange={this.changeData}
addonBefore={<IconFont type="icon-password" style={{ fontSize: "0.3rem" }} />} addonBefore={
<IconFont type="icon-password" style={{ fontSize: "0.3rem" }} />
}
placeholder="重复密码" placeholder="重复密码"
/> />
{current === RESET_PASSWORD_TYPE ? (
<Input <Input
type="text" type="text"
size="large" size="large"
name="authCode" name="authCode"
value={authCode} value={authCode}
onChange={this.changeData} onChange={this.changeData}
addonBefore={<IconFont type="icon-yanzhengma54" style={{ fontSize: "0.3rem" }} />} addonBefore={
<IconFont
type="icon-yanzhengma54"
style={{ fontSize: "0.3rem" }}
/>
}
addonAfter={ addonAfter={
<span style={{ cursor: isCountDown ? "" : "pointer" }} onClick={this.getCode}> <span
style={{ cursor: isCountDown ? "" : "pointer" }}
onClick={this.getCode}
>
{authCodeText} {authCodeText}
</span> </span>
} }
placeholder="验证码" placeholder="验证码"
/> />
<Button type="primary" className={styles.submit} onClick={this.submit} block loading={isLoading}> ) : null}
<Button
type="primary"
className={styles.submit}
onClick={this.submit}
block
loading={isLoading}
>
{current === REGISTER_TYPE ? "注册" : "重置密码"} {current === REGISTER_TYPE ? "注册" : "重置密码"}
</Button> </Button>
</div> </div>