Get login form working!

stable/1.0.x
Alex Gleason 2020-04-05 20:29:19 -05:00
rodzic 83a711cd3e
commit 9e50293e67
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
3 zmienionych plików z 13 dodań i 8 usunięć

Wyświetl plik

@ -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',

Wyświetl plik

@ -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();
}

Wyświetl plik

@ -74,10 +74,11 @@ class WrappedRoute extends React.Component {
if (!publicRoute && me == false) {
const actualUrl = encodeURIComponent(this.props.computedMatch.url);
return <Route path={this.props.path} component={() => {
window.location.href = `/auth/sign_in?redirect_uri=${actualUrl}`;
return null;
}}/>
return <Redirect to={`/auth/sign_in?redirect_uri=${actualUrl}`} />;
// return <Route path={this.props.path} component={() => {
// window.location.href = `/auth/sign_in?redirect_uri=${actualUrl}`;
// return null;
// }}/>
}
return <Route {...rest} render={this.renderComponent} />;