Commit f7bfe813 authored by 2breakegg's avatar 2breakegg

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/routes/Index.js
#	yarn.lock
parents 10470369 d8e3bbe7
src/assets/MoeCube.png

95 KB | W: | H:

src/assets/MoeCube.png

68.9 KB | W: | H:

src/assets/MoeCube.png
src/assets/MoeCube.png
src/assets/MoeCube.png
src/assets/MoeCube.png
  • 2-up
  • Swipe
  • Onion skin
export default {
apiRoot: 'http://192.168.1.9:3000',
apiRoot: 'http://192.168.1.9:3000'
};
import { message } from 'antd';
import { routerRedux } from 'dva/router';
import { activate, checkUserExists, forgot, login, register, reset } from '../services/auth';
import { login, forgot, register, reset, activate, checkUserExists } from '../services/auth'
import { message } from 'antd'
import { routerRedux } from 'dva/router'
import config from '../config'
export default {
......@@ -238,5 +240,12 @@ export default {
}
},
},
subscriptions: {},
subscriptions: {
setup({ dispatch, history }) {
return history.listen(({ pathname, query }) => {
})
}
}
};
export default {
namespace: 'haha',
state: {
text: '123213213',
},
reducers: {
change(state, action) {
return {
...state, ...action.payload
};
},
},
effects: {},
subscriptions: {},
};
......@@ -48,5 +48,7 @@ export default {
}
},
},
subscriptions: {},
subscriptions: {
},
};
......@@ -2,6 +2,7 @@ import { routerRedux } from 'dva/router'
import { updateProfile, updateAccount } from '../services/user'
import { getAuthUser } from '../services/auth'
import { message } from 'antd'
import { handleSSO } from '../utils/sso'
......@@ -89,35 +90,55 @@ export default {
localStorage.setItem("token", token)
}
if(user && user.active) {
if(user) {
if(handleSSO(user)){
return
}
if(user.active) {
yield put(routerRedux.replace("/profiles"))
// message.info("登录成功")
} else {
yield put(routerRedux.replace(`/verify`))
}
}
},
*preLogin({ payload }, { call, put }) {
let token = localStorage.getItem("token")
const {token } = payload
if(!token) {
yield put(routerRedux.replace("/signin"))
}
try {
let { data } = yield call(getAuthUser, { token })
if (data ) {
yield put({ type: 'preLoginSuccess', payload: { user: data, token }})
if(data) {
if(handleSSO(user)){
return
}
if(data.active) {
// yield put(routerRedux.replace("/profiles"))
yield put(routerRedux.replace("/profiles"))
}else {
yield put(routerRedux.replace("/verify"))
}
}
}
} catch (error) {
message.error(error.message)
yield put(routerRedux.replace("/signin"))
}
},
*updateProfile({ payload }, { call, put, select }) {
message.destroy()
try {
let token = yield select(state => state.user.token)
let { messages } = yield select(state => state.common)
try {
let { data } = yield call(updateProfile, {...payload, token})
......@@ -165,10 +186,16 @@ export default {
},
subscriptions: {
setup({ dispatch, history }) {
let token = localStorage.getItem("token")
return history.listen(({ pathname, query }) => {
if (pathname == '/profiles') {
dispatch({ type: 'preLogin', payload: query })
if(pathname == '/' || pathname == 'profiles') {
dispatch({ type: 'preLogin', payload: { token } })
}
if(pathname == 'profiles' && !token) {
history.push("/signin")
}
})
}
......
......@@ -21,16 +21,16 @@ import Index from "./routes/Index.js";
function RouterConfig({ history }) {
return (
<Router history={history}>
<Redirect from="/" to="/signin"/>
<Route path="/" component={Index} >
<Redirect from="/home" to="/profiles" />
<Route path="/signin" component={Login}/>
<Route path="/forgot" component={Forgot}/>
<Route path="/signup" component={Register}/>
<Route path="/reset" component={Reset}/>
<Route path="/profiles" component={Profiles}/>
</Route>
<Route path="/activate" component={Active}/>
<Route path="/verify" component={Verify} />
</Route>
</Router>
);
}
......
import { connect } from 'dva';
import React from 'react';
import DocumentTitle from 'react-document-title';
import Particles from 'react-particles-js';
import { connect } from 'dva';
import styles from './Index.less';
import Particles from 'react-particles-js'
import DocumentTitle from 'react-document-title'
import { Layout, Button, Menu } from 'antd';
import { Link } from 'dva/router'
import logo from '../assets/MoeCube.png'
const { Header, Footer, Sider, Content } = Layout;
function Index({ children, messages }) {
return (
<div style={{ height: '100%' }}>
<DocumentTitle title={messages['title'] || 'Moe Cube'}>
<Particles
params={{
const particleConfig = {
'particles': {
'number': {
'value': 20,
'density': {
'enable': true,
'value_area': 1000,
},
'value_area': 1000
}
},
'color': {
'value': '#888',
'opacity': 0.4,
'opacity': 0.4
},
'shape': {
'type': 'circle',
'stroke': {
'width': 4,
'color': '#888',
'opacity': 0.4,
'opacity': 0.4
},
'polygon': {
'nb_sides': 5,
'nb_sides': 5
},
'image': {
'src': 'img/github.svg',
'width': 100,
'height': 100,
},
'height': 100
}
},
'opacity': {
'value': 0.5,
......@@ -44,8 +45,8 @@ function Index({ children, messages }) {
'enable': false,
'speed': 1,
'opacity_min': 0.1,
'sync': false,
},
'sync': false
}
},
'size': {
'value': 3,
......@@ -54,15 +55,15 @@ function Index({ children, messages }) {
'enable': false,
'speed': 1,
'size_min': 0.1,
'sync': false,
},
'sync': false
}
},
'line_linked': {
'enable': true,
'distance': 150,
'color': '#888',
'opacity': 0.4,
'width': 1,
'width': 1
},
'move': {
'enable': true,
......@@ -75,9 +76,9 @@ function Index({ children, messages }) {
'attract': {
'enable': false,
'rotateX': 600,
'rotateY': 1200,
},
},
'rotateY': 1200
}
}
},
'interactivity': {
'detect_on': 'canvas',
......@@ -85,58 +86,87 @@ function Index({ children, messages }) {
'onhover': {
'enable': true,
'mode': 'grab',
'nb': 2,
'nb': 2
},
'onclick': {
'enable': true,
'mode': 'push',
'mode': 'push'
},
'resize': true,
'resize': true
},
'modes': {
'grab': {
'distance': 400,
'line_linked': {
'opacity': 0.4,
},
'opacity': 0.4
}
},
'bubble': {
'distance': 400,
'size': 20,
'duration': 2,
'opacity': 8,
'speed': 1,
'speed': 1
},
'repulse': {
'distance': 200,
'duration': 0.4,
'duration': 0.4
},
'push': {
'particles_nb': 4,
'particles_nb': 4
},
'remove': {
'particles_nb': 2,
},
},
'particles_nb': 2
}
}
},
'retina_detect': true,
}}
'retina_detect': true
}
function Index({ dispatch, children, messages }) {
return (
<div style={{ height: "100%" }}>
<DocumentTitle title={messages['title'] || 'Moe Cube'} />
<Header style={{ display: 'flex', alignItems: 'center'}}>
<Link to="/home" style={{ marginTop: '20px'}}>
<img src={logo} style={{ width: '140px', height: '44px'}}/>
</Link>
<Menu
theme="dark"
mode="horizontal"
defaultSelectedKeys={['1']}
style={{ lineHeight: '64px' }}>
<Menu.Item key="1">
<Link to="/home">
Home
</Link>
</Menu.Item>
</Menu>
</Header>
<Particles
params={particleConfig}
style={{
position: 'fixed',
position: "fixed"
}}
/>
</DocumentTitle>
{children}
<Footer style={{ position: 'absolute', width: '100%', bottom: 0, left: 0, display: 'flex', justifyContent: 'space-between' }}>
<div>© MoeCube 2017 all right reserved.</div>
</Footer>
</div>
);
}
function mapStateToProps(state) {
const {
common: { messages },
} = state;
common: { messages }
} = state
return {
messages,
messages
};
}
......
......@@ -38,9 +38,7 @@ class Login extends React.Component {
return (
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100%' }}>
<Spin spinning={loading} delay={100}>
<FormItem style={{display: 'flex', justifyContent:'center'}}>
<img src={logo} style={{height:'20vw', width: '20vw'}}/>
</FormItem>
<Form onSubmit={this.onSubmitLogin} className="login-form">
<FormItem>
{getFieldDecorator('account', {
......
import crypto from 'crypto'
import "url-api-polyfill";
const url = new URL(window.location)
let sso
let ssoString = url.searchParams.get('sso')
if (ssoString) {
sso = new URLSearchParams(Buffer.from(ssoString, 'base64').toString())
}
export const handleSSO = (user) => {
if(sso) {
let params = new URLSearchParams()
let url = new URL(sso.get("return_sso_url"));
for (let [key, value] of Object.entries(user)) {
params.set(key, value)
}
params.set("return_sso_url", sso.get("return_sso_url"))
params.set("nonce", sso.get("nonce"))
params.set("external_id", user.id)
let payload = Buffer.from(params.toString()).toString('base64')
url.searchParams.set("sso", payload)
url.searchParams.set('sig', crypto.createHmac('sha256', 'zsZv6LXHDwwtUAGa').update(payload).digest('hex'))
window.location.href = url
return true
}else {
return false
}
}
\ No newline at end of file
This diff is collapsed.
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