OAuth frontend fixes and cleanup.
parent
4039bfea0c
commit
8b6fd20a7f
|
@ -4,13 +4,13 @@ import {connect} from 'react-redux'
|
||||||
|
|
||||||
const {array} = PropTypes
|
const {array} = PropTypes
|
||||||
|
|
||||||
const Login = ({auths}) => (
|
const Login = ({auth}) => (
|
||||||
<div className="auth-page">
|
<div className="auth-page">
|
||||||
<div className="auth-box">
|
<div className="auth-box">
|
||||||
<div className="auth-logo"></div>
|
<div className="auth-logo"></div>
|
||||||
<h1 className="auth-text-logo">Chronograf</h1>
|
<h1 className="auth-text-logo">Chronograf</h1>
|
||||||
<p><strong>{VERSION}</strong> / Time-Series Data Visualization</p>
|
<p><strong>{VERSION}</strong> / Time-Series Data Visualization</p>
|
||||||
{auths.map(({name, login, label}) => (
|
{auth.map(({name, login, label}) => (
|
||||||
<a key={name} className="btn btn-primary" href={login}>
|
<a key={name} className="btn btn-primary" href={login}>
|
||||||
<span className={`icon ${name}`}></span>
|
<span className={`icon ${name}`}></span>
|
||||||
Login with {label}
|
Login with {label}
|
||||||
|
@ -23,13 +23,11 @@ const Login = ({auths}) => (
|
||||||
)
|
)
|
||||||
|
|
||||||
Login.propTypes = {
|
Login.propTypes = {
|
||||||
auths: array.isRequired,
|
auth: array.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => ({
|
||||||
return {
|
auth: state.auth,
|
||||||
auths: state.auth,
|
})
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default connect(mapStateToProps)(Login)
|
export default connect(mapStateToProps)(Login)
|
||||||
|
|
|
@ -70,11 +70,15 @@ const Root = React.createClass({
|
||||||
if (store.getState().me.links) {
|
if (store.getState().me.links) {
|
||||||
return this.setState({loggedIn: true});
|
return this.setState({loggedIn: true});
|
||||||
}
|
}
|
||||||
getMe().then(({data: {me, auth}}) => {
|
getMe().then(({data: me, auth}) => {
|
||||||
store.dispatch(receiveMe(me));
|
store.dispatch(receiveMe(me));
|
||||||
store.dispatch(receiveAuth(auth));
|
store.dispatch(receiveAuth(auth));
|
||||||
this.setState({loggedIn: true});
|
this.setState({loggedIn: true});
|
||||||
}).catch(() => {
|
}).catch((error) => {
|
||||||
|
if (error.auth) {
|
||||||
|
store.dispatch(receiveAuth(error.auth));
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({loggedIn: false});
|
this.setState({loggedIn: false});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
function getInitialState() {
|
function getInitialState() {
|
||||||
return {};
|
return [];
|
||||||
}
|
}
|
||||||
const initialState = getInitialState();
|
const initialState = getInitialState();
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ export default async function AJAX({
|
||||||
if (!response.status === UNAUTHORIZED) {
|
if (!response.status === UNAUTHORIZED) {
|
||||||
console.error(error) // eslint-disable-line no-console
|
console.error(error) // eslint-disable-line no-console
|
||||||
}
|
}
|
||||||
throw {response} // eslint-disable-line no-throw-literal
|
const {auth} = links
|
||||||
|
throw {auth, ...response} // eslint-disable-line no-throw-literal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue