密码加密
This commit is contained in:
parent
9e5cc98762
commit
58244b113c
|
|
@ -21,6 +21,8 @@
|
|||
"code-prettify": "^0.1.0",
|
||||
"codemirror": "^5.64.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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import styled from 'styled-components';
|
|||
import UploadImage from '../Component/UploadImage';
|
||||
import axios from 'axios';
|
||||
import Modals from '../Component/Modals';
|
||||
import { Encrypt } from '../../../common/Env';
|
||||
|
||||
import { getImageUrl } from 'educoder';
|
||||
const TextArea = Input.TextArea;
|
||||
|
|
@ -91,7 +92,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){
|
||||
// 删除后跳转到个人中心的组织页面
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import img1 from '../../Images/personalInfo3.png';
|
|||
import { setmiyah } from '../../../common/Component';
|
||||
import { useEffect } from 'react';
|
||||
import Phone from './Phone';
|
||||
import { Encrypt } from '../../../common/Env';
|
||||
|
||||
export default Form.create()(
|
||||
forwardRef((props)=>{
|
||||
|
|
@ -104,7 +105,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'){
|
||||
|
|
@ -153,6 +154,8 @@ export default Form.create()(
|
|||
}else{
|
||||
setEmailValue(undefined);
|
||||
map.email = undefined;
|
||||
// 防止已经输入过验证码但是还未输入邮箱地址
|
||||
setFieldsValue({code:""})
|
||||
setPassMap(map);
|
||||
callback(res.data.message);
|
||||
}
|
||||
|
|
@ -206,7 +209,7 @@ export default Form.create()(
|
|||
const {code, email, password1} = getFieldsValue();
|
||||
if( email && password1){
|
||||
current_user && Axios.patch(`/v1/${current_user.login}/update_email.json`,{
|
||||
code:"123123", email, password: password1
|
||||
code:"123123", email, password:Encrypt(password1)
|
||||
}).then(res=>{
|
||||
if(res && !res.data.status){
|
||||
setPassMap({password: undefined, email: undefined, code: undefined});
|
||||
|
|
@ -222,10 +225,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;
|
||||
|
|
@ -148,7 +149,7 @@ export default Form.create()(
|
|||
const {mescode, phone, logpassword} = getFieldsValue();
|
||||
if(phone && logpassword){
|
||||
current_user && Axios.patch(`/v1/${current_user.login}/update_phone.json`,{
|
||||
code:"123123", phone, password:logpassword
|
||||
code:"123123", phone, password: Encrypt(logpassword)
|
||||
}).then(res=>{
|
||||
if(res && !res.data.status){
|
||||
setPassMap({logpassword: undefined, phone: undefined, code: undefined});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,73 @@
|
|||
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)=>{
|
||||
const { getFieldDecorator , validateFields } = props && props.form;
|
||||
const { onCancel, visible , current_user} = props;
|
||||
const [ loading , setLoading ] =useState(false);
|
||||
|
||||
|
||||
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,password:Encrypt(password)}
|
||||
}).then(result=>{
|
||||
if(result.data && result.data.status === 0){
|
||||
window.location.href = `/`;
|
||||
onCancel();
|
||||
}
|
||||
setLoading(false);
|
||||
}).catch(error=>{setLoading(false);})
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
return(
|
||||
<Modal
|
||||
title="注销账号"
|
||||
width={560}
|
||||
visible={visible}
|
||||
footer={null}
|
||||
onCancel={onCancel}
|
||||
destroyOnClose={true}
|
||||
>
|
||||
<div>
|
||||
<p className='AlignCenter font-bd font-17'><i className='iconfont icon-shanchu_important font-25 color-red mr5'/>是否仍要注销?</p>
|
||||
<p className='mt15'>注销后你将丢失该帐号产生的所有数据,一旦注销相关数据将不可恢复,请输入登录密码再次确认</p>
|
||||
<Form className='mt25'>
|
||||
<Form.Item label="密码校验">
|
||||
{getFieldDecorator("password",{
|
||||
rules:[
|
||||
{required:true,message:"请输入登录密码"},
|
||||
// {validator:(rule, value, callback)=>checkNewPass(rule, value, callback, NewPassRepeat)}
|
||||
],
|
||||
validateFirst: true,
|
||||
validateTrigger:"onBlur",
|
||||
})(
|
||||
<Input.Password placeholder="请输入登录密码"/>
|
||||
)}
|
||||
</Form.Item>
|
||||
<Form.Item label="注销原因">
|
||||
{getFieldDecorator("memo",{
|
||||
rules:[{required:true,message:"请输入注销原因"}],
|
||||
})(
|
||||
<TextArea rows={3} maxLength={500} placeholder="我们非常遗憾看到您想要注销账号。在您做出最终决定之前,请告诉我们您注销的原因,这将帮助我们改进社区服务。您的反馈对我们至关重要。"
|
||||
/>
|
||||
)}
|
||||
</Form.Item>
|
||||
</Form>
|
||||
<div style={{textAlign:"center"}}>
|
||||
<Button onClick={onDelete} style={{minWidth:"95px"}} loading={loading}>仍要注销</Button>
|
||||
<Button type={"primary"} style={{width:"95px"}} className='ml25' onClick={onCancel}>再想想</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
)})
|
||||
)
|
||||
|
|
@ -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){
|
|||
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: "123123"
|
||||
}).then((response)=>{
|
||||
debugger;
|
||||
|
|
|
|||
|
|
@ -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