邮箱不通过再清除验证码
This commit is contained in:
parent
028d7102c4
commit
692428bfd3
|
@ -44,6 +44,7 @@
|
|||
"connect-timeout": "^1.9.0",
|
||||
"connected-react-router": "4.4.1",
|
||||
"core-js": "^3.34.0",
|
||||
"crypto-js": "^4.2.0",
|
||||
"dompurify": "^2.3.3",
|
||||
"dotenv": "4.0.0",
|
||||
"dotenv-expand": "4.2.0",
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import CryptoJS from 'crypto-js';
|
||||
|
||||
export function isDev() {
|
||||
return window.location.port === "3007";
|
||||
}
|
||||
|
@ -6,3 +8,12 @@ export function isDev() {
|
|||
export const isMobile = (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase()));
|
||||
|
||||
// const isWeiXin = (/MicroMessenger/i.test(navigator.userAgent.toLowerCase()));
|
||||
|
||||
export function Encrypt(str){
|
||||
let result = CryptoJS.AES.encrypt(str,CryptoJS.enc.Utf8.parse('59c96c3572ab8cc1'),{
|
||||
iv:CryptoJS.enc.Utf8.parse('59c96c3572ab8cc1'),
|
||||
mode: CryptoJS.mode.CBC,
|
||||
padding: CryptoJS.pad.Pkcs7
|
||||
})
|
||||
return result.toString();
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import styled from 'styled-components';
|
|||
import axios from 'axios';
|
||||
import Modals from '../Component/Modals';
|
||||
import AvatarModal from '../../users/Avatar/Index';
|
||||
import { Encrypt } from '../../../common/Env';
|
||||
|
||||
import { getImageUrl } from 'educoder';
|
||||
const TextArea = Input.TextArea;
|
||||
|
@ -93,7 +94,7 @@ export default Form.create()(
|
|||
function onOk(password){
|
||||
const url = `/organizations/${organizeDetail.id}.json`;
|
||||
axios.delete(url,{
|
||||
params:{ password }
|
||||
params:{ password:Encrypt(password) }
|
||||
}).then(result=>{
|
||||
if(result && result.data){
|
||||
// 删除后跳转到个人中心的组织页面
|
||||
|
|
|
@ -8,6 +8,7 @@ import { setmiyah } from '../../../common/Component';
|
|||
import { useEffect } from 'react';
|
||||
import Phone from './Phone';
|
||||
import OffAccount from './component/offAccount';
|
||||
import { Encrypt } from '../../../common/Env';
|
||||
|
||||
export default Form.create()(
|
||||
forwardRef((props)=>{
|
||||
|
@ -108,7 +109,7 @@ export default Form.create()(
|
|||
const map = type === '0' ? passMap : updatePsdMap;
|
||||
if(value){
|
||||
current_user && Axios.post(`/v1/${current_user.login}/check_password.json`,{
|
||||
password: value
|
||||
password: Encrypt(value)
|
||||
}).then(res=>{
|
||||
if(res && !res.data.status){
|
||||
if(type === '0'){
|
||||
|
@ -157,11 +158,11 @@ export default Form.create()(
|
|||
}else{
|
||||
setEmailValue(undefined);
|
||||
map.email = undefined;
|
||||
// 防止已经输入过验证码但是还未输入邮箱地址
|
||||
setFieldsValue({code:""})
|
||||
setPassMap(map);
|
||||
callback(res.data.message);
|
||||
}
|
||||
// 防止已经输入过验证码但是还未输入邮箱地址
|
||||
setFieldsValue({code:""})
|
||||
})
|
||||
}else{
|
||||
setEmailValue(undefined);
|
||||
|
@ -211,7 +212,7 @@ export default Form.create()(
|
|||
const {code, email, password1} = getFieldsValue();
|
||||
if(code && email && password1){
|
||||
current_user && Axios.patch(`/v1/${current_user.login}/update_email.json`,{
|
||||
code, email, password: password1
|
||||
code, email, password:Encrypt(password1)
|
||||
}).then(res=>{
|
||||
if(res && !res.data.status){
|
||||
setPassMap({password: undefined, email: undefined, code: undefined});
|
||||
|
@ -227,10 +228,13 @@ export default Form.create()(
|
|||
}
|
||||
}else{
|
||||
const values = getFieldsValue();
|
||||
const { old_password , password , new_password_repeat } = values;
|
||||
const url = `/accounts/change_password.json`;
|
||||
Axios.post(url,{
|
||||
login:current_user && current_user.login,
|
||||
...values
|
||||
old_password:Encrypt(old_password),
|
||||
password:Encrypt(password),
|
||||
new_password_repeat:Encrypt(new_password_repeat),
|
||||
}).then(result=>{
|
||||
if(result && result.data){
|
||||
resetFields();
|
||||
|
|
|
@ -4,6 +4,7 @@ import Modals from '../../Component/PublicModal/Index';
|
|||
import { AlignCenter } from '../../Component/layout';
|
||||
import img1 from '../../Images/personalInfo3.png';
|
||||
import { setmiyah } from '../../../common/Component';
|
||||
import { Encrypt } from '../../../common/Env';
|
||||
import Axios from 'axios';
|
||||
|
||||
|
||||
|
@ -21,7 +22,7 @@ export default Form.create()(
|
|||
const map = passMap;
|
||||
if(value){
|
||||
current_user && value.length > 7 && Axios.post(`/v1/${current_user.login}/check_password.json`,{
|
||||
password: value
|
||||
password: Encrypt(value)
|
||||
}).then(res=>{
|
||||
if(res && !res.data.status){
|
||||
map.logpassword = value;
|
||||
|
@ -147,7 +148,7 @@ export default Form.create()(
|
|||
const {mescode, phone, logpassword} = getFieldsValue();
|
||||
if(mescode && phone && logpassword){
|
||||
current_user && Axios.patch(`/v1/${current_user.login}/update_phone.json`,{
|
||||
code:mescode, phone, password:logpassword
|
||||
code:mescode, phone, password: Encrypt(logpassword)
|
||||
}).then(res=>{
|
||||
if(res && !res.data.status){
|
||||
setPassMap({logpassword: undefined, phone: undefined, code: undefined});
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import React , { forwardRef, useState } from 'react';
|
||||
import { Modal , Form , Button , Input } from 'antd';
|
||||
import Axios from 'axios';
|
||||
import { Encrypt } from '../../../../common/Env';
|
||||
const { TextArea } = Input;
|
||||
|
||||
export default Form.create()(forwardRef((props)=>{
|
||||
|
@ -12,10 +13,11 @@ export default Form.create()(forwardRef((props)=>{
|
|||
function onDelete(){
|
||||
validateFields((error,values)=>{
|
||||
if(!error && current_user){
|
||||
const { password } = values;
|
||||
setLoading(true);
|
||||
const url = `/v1/${current_user.login}.json`;
|
||||
Axios.delete(url,{
|
||||
data:{...values}
|
||||
data:{...values,password:Encrypt(password)}
|
||||
}).then(result=>{
|
||||
if(result.data && result.data.status === 0){
|
||||
window.location.href = `/`;
|
||||
|
|
|
@ -10,6 +10,7 @@ import axios from 'axios';
|
|||
import OtherLogin from "./component/otherLogin";
|
||||
import cookie from 'react-cookies';
|
||||
import './LoginRegisterPage.scss';
|
||||
import { Encrypt } from "../../common/Env";
|
||||
|
||||
function Login(props){
|
||||
const [message,setMessage] = useState();
|
||||
|
@ -18,6 +19,7 @@ function Login(props){
|
|||
const {getFieldDecorator } = form;
|
||||
const {search} = location;
|
||||
|
||||
|
||||
useEffect(()=>{
|
||||
//控制密码输入框在DOM不可见value
|
||||
clear();
|
||||
|
@ -40,7 +42,7 @@ function Login(props){
|
|||
if (!err) {
|
||||
axios.post(`/accounts/login.json`, {
|
||||
login: values.username,
|
||||
password: values.password,
|
||||
password: Encrypt(values.password),
|
||||
autologin: values.remember?1:0,
|
||||
}).then((response) => {
|
||||
if (!response.data.login) {
|
||||
|
|
|
@ -5,6 +5,7 @@ import axios from 'axios';
|
|||
import { setmiyah } from 'educoder';
|
||||
import './LoginRegisterPage.scss';
|
||||
import OtherLogin from "./component/otherLogin";
|
||||
import { Encrypt } from "../../common/Env";
|
||||
|
||||
function Register(props){
|
||||
const {form, mygetHelmetapi} = props;
|
||||
|
@ -47,8 +48,8 @@ function Register(props){
|
|||
values.agreement && axios.post(`/accounts/register.json`, {
|
||||
login: values.email,
|
||||
namespace: values.register_username.trim(),
|
||||
password: values.register_psd,
|
||||
password_confirmation: values.psdComfirm,
|
||||
password: Encrypt(values.register_psd),
|
||||
password_confirmation: Encrypt(values.psdComfirm),
|
||||
code: values.captcha
|
||||
}).then((response)=>{
|
||||
if(response.data && response.data.status === -6){
|
||||
|
|
|
@ -33,8 +33,8 @@ function ResetPassword(props) {
|
|||
if (!err) {
|
||||
axios.post(`/accounts/reset_password.json`, {
|
||||
login: values.email,
|
||||
password: values.psd,
|
||||
password_confirmation: values.psdComfirm,
|
||||
password: Encrypt(values.psd),
|
||||
password_confirmation: Encrypt(values.psdComfirm),
|
||||
code: values.captcha,
|
||||
}).then((response) => {
|
||||
if (response.data.status === 0) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import {setmiyah} from 'educoder';
|
|||
import CheckInputysl1 from './CheckInputysl';
|
||||
import CheckInputysl2 from './CheckInputysl';
|
||||
import {Tabs, Input, Checkbox, Button, notification} from 'antd';
|
||||
|
||||
import { Encrypt } from '../../common/Env';
|
||||
|
||||
import ReadPassword from './ReadPassword';
|
||||
|
||||
|
@ -262,8 +262,8 @@ class LoginRegisterComponent extends Component {
|
|||
axios.post(url, {
|
||||
login: this.state.login,
|
||||
code: this.state.codes,
|
||||
new_password: this.state.password,
|
||||
new_password_confirmation: this.state.passwords,
|
||||
new_password: Encrypt(this.state.password),
|
||||
new_password_confirmation: Encrypt(this.state.passwords),
|
||||
}).then((result) => {
|
||||
// console.log(result);
|
||||
//登录成功,会生成session
|
||||
|
|
Loading…
Reference in New Issue