<commit_before>import React, {Component, PropTypes} from 'react'
import {connect} from 'react-redux'
import {push} from 'react-router-redux'

import {setUser} from './actions'
import {lock} from './auth0'

class Login extends Component {
  static propTypes = {
    push: PropTypes.func.isRequired,
    setUser: PropTypes.func.isRequired
  }

  componentDidMount () {
    lock.show({
      authParams: {
        scope: 'openid analyst offline_access'
      }
    },
    (err, profile, id_token, access_token, state, refresh_token) => {
      if (err) {
        window.alert(err)
        console.error(err)
      } else {
        this.props.setUser({access_token, id_token, profile, refresh_token})
        this.props.push('/')
      }
    })
  }

  render () {
    return <p> You must be logged in to use the scenario editor. </p>
  }
}

function mapDispatchToProps (dispatch) {
  return {
    push: (path) => dispatch(push(path)),
    setUser: (user) => dispatch(setUser(user))
  }
}

export default connect((state) => state, mapDispatchToProps)(Login)<commit_msg>Show log in error as alert<commit_after>import React, {Component, PropTypes} from 'react'
import {connect} from 'react-redux'
import {push} from 'react-router-redux'

import {setUser} from './actions'
import {lock} from './auth0'

class Login extends Component {
  static propTypes = {
    push: PropTypes.func.isRequired,
    setUser: PropTypes.func.isRequired
  }

  componentDidMount () {
    lock.show({
      authParams: {
        scope: 'openid analyst offline_access'
      }
    },
    (err, profile, id_token, access_token, state, refresh_token) => {
      if (err) {
        window.alert(err)
        console.error(err)
      } else {
        this.props.setUser({access_token, id_token, profile, refresh_token})
        this.props.push('/')
      }
    })
  }

  render () {
    return <div className='alert alert-danger'> You must be logged in to use the scenario editor.</div>
  }
}

function mapDispatchToProps (dispatch) {
  return {
    push: (path) => dispatch(push(path)),
    setUser: (user) => dispatch(setUser(user))
  }
}

export default connect((state) => state, mapDispatchToProps)(Login)
{'fraction_non_alphanumeric': 0.13333333333333333, 'fraction_numerical': 0.0009195402298850574, 'mean_word_length': 3.121212121212121, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6132081', 'n_tokens_mistral': 684, 'n_tokens_neox': 681, 'n_words': 173}