<commit_before>import React, { Component } from 'react'
import { connect } from 'react-redux'
import { userLogoutReq, userLoginReq, userLoginLocalStorage } from '../actions/user-actions'
import _ from 'lodash'
import '../styles/LoginPage.css'

class LoginPage extends Component {
  constructor(props) {
    super(props)

    this.handleSignIn = this.handleSignIn.bind(this)
    this.handleSignOut = this.handleSignOut.bind(this)
    this.renderLogin = this.renderLogin.bind(this)
    this.renderLogout = this.renderLogout.bind(this)
  }

  componentWillMount() {
    console.log('rendering log-in', this.props)
    const auth = localStorage.getItem('user')
    if (auth) {
      this.props.submitLocalStorageAuth(auth)
    }
    console.log('this is the user', auth)
  }

  handleSignIn(e, provider) {
    e.preventDefault();
    return this.props.login(provider)
  }

  handleSignOut(e) {
    e.preventDefault();
    return this.props.logout();
  }

  renderLogout() {
    return (
      <div>
        <h1>You are already logged in</h1>
        <button onClick={(e) => this.handleSignOut(e)}>Logout</button>
      </div>
    )
  }

  renderLogin() {
    return (
      <div className="login-container">
        <button
          className='login-button github'
          onClick={(e) => this.handleSignIn(e, 'github')} >
          <h3>Github</h3>
        </button>
        <button
          className='login-button facebook'
          onClick={(e) => this.handleSignIn(e, 'facebook')} >
          <h3>Facebook</h3>
        </button>
        <button
          className='login-button google'
          onClick={(e) => this.handleSignIn(e, 'google')} >
          <h3>Google</h3>
        </button>
        <button
          className='login-button twitter'
          onClick={(e) => this.handleSignIn(e, 'twitter')} >
          <h3>Twitter</h3>
        </button>
      </div>
    )
  }

  render() {
    return (
      <div>
        {
          !this.props.user ? this.renderLogin() : this.renderLogout()
        }
    </div>
    )
  }
}

const mapStateToProps = (state) => {
  return {
    user: _.isEmpty(state.user) ? null : state.user
  }
}

const mapDispatchToProps = (dispatch) => {
  return {
    login: (provider) => {
      dispatch(userLoginReq(provider))
    },
    logout: () => {
      dispatch(userLogoutReq())
    },
    submitLocalStorageAuth: (authData) => {
      dispatch(userLoginLocalStorage(authData))
    }
  }
}

const LoginContainer = connect(
  mapStateToProps,
  mapDispatchToProps
)(LoginPage)

export default LoginContainer;<commit_msg>move login check to the index<commit_after>import React, { Component } from 'react'
import { connect } from 'react-redux'
import { userLogoutReq, userLoginReq, userLoginLocalStorage } from '../actions/user-actions'
import _ from 'lodash'
import '../styles/LoginPage.css'

class LoginPage extends Component {
  constructor(props) {
    super(props)

    this.handleSignIn = this.handleSignIn.bind(this)
    this.handleSignOut = this.handleSignOut.bind(this)
    this.renderLogin = this.renderLogin.bind(this)
    this.renderLogout = this.renderLogout.bind(this)
  }

  handleSignIn(e, provider) {
    e.preventDefault();
    return this.props.login(provider)
  }

  handleSignOut(e) {
    e.preventDefault();
    return this.props.logout();
  }

  renderLogout() {
    return (
      <div>
        <h1>You are already logged in</h1>
        <button onClick={(e) => this.handleSignOut(e)}>Logout</button>
      </div>
    )
  }

  renderLogin() {
    return (
      <div className="login-container">
        <button
          className='login-button github'
          onClick={(e) => this.handleSignIn(e, 'github')} >
          <h3>Github</h3>
        </button>
        <button
          className='login-button facebook'
          onClick={(e) => this.handleSignIn(e, 'facebook')} >
          <h3>Facebook</h3>
        </button>
        <button
          className='login-button google'
          onClick={(e) => this.handleSignIn(e, 'google')} >
          <h3>Google</h3>
        </button>
        <button
          className='login-button twitter'
          onClick={(e) => this.handleSignIn(e, 'twitter')} >
          <h3>Twitter</h3>
        </button>
      </div>
    )
  }

  render() {
    return (
      <div>
        { this.props.user ? this.renderLogout() : this.renderLogin() }
    </div>
    )
  }
}

const mapStateToProps = (state) => {
  return {
    user: _.isEmpty(state.user) ? null : state.user
  }
}

const mapDispatchToProps = (dispatch) => {
  return {
    login: (provider) => {
      dispatch(userLoginReq(provider))
    },
    logout: () => {
      dispatch(userLogoutReq())
    }
  }
}

const LoginContainer = connect(
  mapStateToProps,
  mapDispatchToProps
)(LoginPage)

export default LoginContainer;
{'fraction_non_alphanumeric': 0.14467640918580377, 'fraction_numerical': 0.0041753653444676405, 'mean_word_length': 2.5176211453744495, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 74, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2945730', 'n_tokens_mistral': 1556, 'n_tokens_neox': 1542, 'n_words': 272}