diff --git a/app/gabsocial/actions/auth.js b/app/gabsocial/actions/auth.js index ff3b68c47..1ff3648d0 100644 --- a/app/gabsocial/actions/auth.js +++ b/app/gabsocial/actions/auth.js @@ -6,7 +6,7 @@ export const AUTH_LOGGED_IN = 'AUTH_LOGGED_IN'; export function createAuthApp() { return (dispatch, getState) => { - api(getState).post('/api/v1/apps', { + return api(getState).post('/api/v1/apps', { // TODO: Add commit hash to client_name client_name: `SoapboxFE_${(new Date()).toISOString()}`, redirect_uris: 'urn:ietf:wg:oauth:2.0:oob', @@ -30,7 +30,7 @@ export function createAuthApp() { export function logIn(username, password) { return (dispatch, getState) => { const app = getState().getIn(['auth', 'app']); - api(getState).post('/oauth/token', { + return api(getState).post('/oauth/token', { client_id: app.get('client_id'), client_secret: app.get('client_secret'), redirect_uri: 'urn:ietf:wg:oauth:2.0:oob', diff --git a/app/gabsocial/features/auth_login/index.js b/app/gabsocial/features/auth_login/index.js index ff6d11fba..91b4a01bd 100644 --- a/app/gabsocial/features/auth_login/index.js +++ b/app/gabsocial/features/auth_login/index.js @@ -3,6 +3,7 @@ import { connect } from 'react-redux' import ImmutablePureComponent from 'react-immutable-pure-component'; import { createAuthApp, logIn } from 'gabsocial/actions/auth'; import { Redirect } from 'react-router-dom'; +import { fetchMe } from 'gabsocial/actions/me'; const mapStateToProps = (state, props) => ({ me: state.get('me'), @@ -21,8 +22,11 @@ class LoginForm extends ImmutablePureComponent { } handleSubmit = (event) => { - const {username, password} = this.getFormData(event.target); - this.props.dispatch(logIn(username, password)); + const { dispatch } = this.props; + const { username, password } = this.getFormData(event.target); + dispatch(logIn(username, password)).then(() => { + dispatch(fetchMe()); + }); event.preventDefault(); } diff --git a/app/gabsocial/features/ui/util/react_router_helpers.js b/app/gabsocial/features/ui/util/react_router_helpers.js index 284cc38d2..317736ae3 100644 --- a/app/gabsocial/features/ui/util/react_router_helpers.js +++ b/app/gabsocial/features/ui/util/react_router_helpers.js @@ -74,10 +74,11 @@ class WrappedRoute extends React.Component { if (!publicRoute && me == false) { const actualUrl = encodeURIComponent(this.props.computedMatch.url); - return { - window.location.href = `/auth/sign_in?redirect_uri=${actualUrl}`; - return null; - }}/> + return ; + // return { + // window.location.href = `/auth/sign_in?redirect_uri=${actualUrl}`; + // return null; + // }}/> } return ;