Commit bc6030d8 by zhanghaozhe

encryption

parent 0fc9a0ec
import React, {Component} from 'react' import React, {Component} from 'react'
import Routes from './router' import Routes from './router'
import cookie from 'js-cookie' import cookie from 'js-cookie'
import {api} from '@/utils'
//拦截ajax请求,返回mock数据 //拦截ajax请求,返回mock数据
/*import mock from '@/utils/mock' /*import mock from '@/utils/mock'
......
...@@ -2,6 +2,7 @@ import React, { Component } from "react" ...@@ -2,6 +2,7 @@ import React, { Component } from "react"
import './accountLogin.scss' import './accountLogin.scss'
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { withFormik, FastField, Form } from "formik"; import { withFormik, FastField, Form } from "formik";
import { compose } from 'redux';
import Header from "../common/Header"; import Header from "../common/Header";
...@@ -10,17 +11,9 @@ import LoginButton from '../common/LoginButton' ...@@ -10,17 +11,9 @@ import LoginButton from '../common/LoginButton'
import PasswordInput from '../common/passwordInput' import PasswordInput from '../common/passwordInput'
// import VeriCodeButton from '../common/veriCodeInput' // import VeriCodeButton from '../common/veriCodeInput'
// import LoginWays from '../common/LoginWays' // import LoginWays from '../common/LoginWays'
import { encrypt, decrypt } from '@/components/passport/encryption';
class AccountLogin extends Component { class AccountLogin extends Component {
componentDidMount() {
}
render() { render() {
return ( return (
<div className={'account-login'}> <div className={'account-login'}>
...@@ -69,4 +62,6 @@ const formikConfig = { ...@@ -69,4 +62,6 @@ const formikConfig = {
console.log(values) console.log(values)
} }
} }
export default withFormik(formikConfig)(AccountLogin) export default compose(
withFormik(formikConfig)
)(AccountLogin)
import aes from 'crypto-js/aes' import aes from 'crypto-js/aes'
import Crypto from 'crypto-js' import Crypto from 'crypto-js'
const key = 'C7D590D00FA968A261BDD5B6CD40DDC2C0561338BF8B9197' const key = Crypto.enc.Hex.parse('C7D590D00FA968A261BDD5B6CD40DDC2C0561338BF8B9197')
const iv = '19513F90B7A8875E469E82195F90EE99' const iv = Crypto.enc.Hex.parse('19513F90B7A8875E469E82195F90EE99')
function encrypt(message) { function encrypt(message) {
return aes.encrypt(message, key, {iv}).toString() return aes.encrypt(message, key, {
iv,
mode: Crypto.mode.CBC,
}).toString()
} }
function decrypt(encrypted) { function decrypt(encrypted) {
......
export const login = (userInfo) => ({
type: 'LOGIN',
userInfo
})
export const logout = () => ({
type: 'LOGOUT'
})
export const requestLogin = payload => dispatch => {
}
\ No newline at end of file
const initialState = {
userName: '',
avatar: '',
uid: '',
isVIP: false
}
const userInfo = (state = initialState, action) => {
switch (action.type) {
case 'LOGIN':
return {
...state,
...action.userInfo
}
default:
return state
}
}
export default userInfo
\ No newline at end of file
...@@ -19,6 +19,12 @@ const config = { ...@@ -19,6 +19,12 @@ const config = {
secure: false, secure: false,
} }
}, },
'passport-api': {
development: '/passport-api',
test: 'http://passport-test.julyedu.com',
production: 'http://passport.julyedu.com',
proxy: {}
},
} }
module.exports = config module.exports = config
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment