Login through homepage working

This commit is contained in:
Alex Gleason 2020-04-10 19:03:06 -05:00
parent 7bbe293537
commit 82a4328700
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
3 changed files with 29 additions and 32 deletions

View file

@ -2,15 +2,11 @@ import React from 'react';
import { connect } from 'react-redux' import { connect } from 'react-redux'
import ImmutablePureComponent from 'react-immutable-pure-component'; import ImmutablePureComponent from 'react-immutable-pure-component';
import { createAuthApp, logIn } from 'gabsocial/actions/auth'; import { createAuthApp, logIn } from 'gabsocial/actions/auth';
import { Redirect } from 'react-router-dom';
import { fetchMe } from 'gabsocial/actions/me'; import { fetchMe } from 'gabsocial/actions/me';
import { Link } from 'react-router-dom';
const mapStateToProps = (state, props) => ({ export default @connect()
me: state.get('me'),
});
class LoginForm extends ImmutablePureComponent { class LoginForm extends ImmutablePureComponent {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = {isLoading: false}; this.state = {isLoading: false};
@ -40,19 +36,23 @@ class LoginForm extends ImmutablePureComponent {
} }
render() { render() {
const { me } = this.props;
if (me) return <Redirect to='/' />;
return ( return (
<form onSubmit={this.handleSubmit}> <form className='simple_form new_user' onSubmit={this.handleSubmit}>
<fieldset disabled={this.state.isLoading}> <fieldset className='fields-group' disabled={this.state.isLoading}>
<input name='username' placeholder='me@example.com' /> <div className='input email optional user_email'>
<input name='password' type='password' placeholder='Password' /> <input aria-label='Username' className='string email optional' placeholder='Username' type='text' name='username' />
<input type='submit' value='Login' /> </div>
<div className='input password optional user_password'>
<input aria-label='Password' className='password optional' placeholder='Password' type='password' name='password' />
</div>
<p className='hint subtle-hint'>
<Link to='/auth/password/new'>Trouble logging in?</Link>
</p>
</fieldset> </fieldset>
<div className='actions'>
<button name='button' type='submit' className='btn button button-primary'>Log in</button>
</div>
</form> </form>
) )
} }
} }
export default connect(mapStateToProps)(LoginForm);

View file

@ -2,6 +2,7 @@ import React from 'react';
import { connect } from 'react-redux' import { connect } from 'react-redux'
import ImmutablePureComponent from 'react-immutable-pure-component'; import ImmutablePureComponent from 'react-immutable-pure-component';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import LoginForm from 'gabsocial/features/auth_login';
const mapStateToProps = (state, props) => ({ const mapStateToProps = (state, props) => ({
instance: state.get('instance'), instance: state.get('instance'),
@ -37,22 +38,7 @@ class LandingPage extends ImmutablePureComponent {
<div className='nav-center'></div> <div className='nav-center'></div>
<div className='nav-right'> <div className='nav-right'>
<div className='hidden-sm'> <div className='hidden-sm'>
<form className='simple_form new_user' id='new_user' noValidate='novalidate' action='/auth/sign_in' acceptCharset='UTF-8' method='post'> <LoginForm />
<div className='fields-group'>
<div className='input email optional user_email'>
<input aria-label='E-mail address' className='string email optional' placeholder='E-mail address' type='email' name='user[email]' id='user_email' />
</div>
<div className='input password optional user_password'>
<input aria-label='Password' className='password optional' placeholder='Password' type='password' name='user[password]' id='user_password' />
</div>
<p className='hint subtle-hint'>
<Link to='/auth/password/new'>Trouble logging in?</Link>
</p>
</div>
<div className='actions'>
<button name='button' type='submit' className='btn button button-primary'>Log in</button>
</div>
</form>
</div> </div>
<div className='visible-sm'> <div className='visible-sm'>
<Link className='webapp-btn nav-link nav-button' to='/auth/sign_in'>Log in</Link> <Link className='webapp-btn nav-link nav-button' to='/auth/sign_in'>Log in</Link>

View file

@ -294,6 +294,17 @@ code {
} }
} }
fieldset[disabled] {
input[type=text],
input[type=number],
input[type=email],
input[type=password],
textarea {
color: rgba($primary-text-color, 0.5);
border-color: rgba($primary-text-color, 0.5);
}
}
input[type=text], input[type=text],
input[type=number], input[type=number],
input[type=email], input[type=email],