<commit_before>import $ from 'jquery';
import React from 'react';
import AioClient from './aioclient';

export default class LoginComponent extends React.Component {
  constructor() {
    super();
    this.state = {
      loggedIn: false,
      username: '',
      pw: '',
      token: '',
      error: '',
      expires: ''
    }
  }

    handleSubmit(e) {
        e.preventDefault()
        const data = { login: this.state.username, password: <PASSWORD> }

        $.ajax({
              url: this.props.url,
              type: "GET",
              success: function(data) {
                console.log("success")
                console.log(data)
                this.setState({
                    token: data.token,
                    expires: 'expires_data',
                    loggedIn: true,
                    error: ''
                });
              }.bind(this),
            crossDomain: true,
            withCredentials: true,
            headers: {
                    'login': this.state.username,
                    'password': <PASSWORD>
                },
              error: function(xhr, status, err) {
                  console.log('error')
                  console.log(xhr);
                  console.log(status);
                  console.log(err);
                this.setState({
                    error: 'Login details not correct'
                });
              }.bind(this)
            });

      // $.post(this.props.url, data).done(function(data) {
        // this.setState({
          // token: data.results.token,
          // expires: data.results.expire_at,
          // loggedIn: true,
          // error: ''
        // });
      // }.bind(this)).fail(function(data) {
        // this.setState({
          // error: 'Login details not correct'
        // });
      // }.bind(this));
  }

  logOut() {
  }

  passInput(state, e) {
    this.setState({
      [state]: e.target.value
    });
  }

  render() {
    return (
      <div>
        <h1>React Login</h1>
        { this.state.loggedIn ? <LoginDetails server={this.props.server} token={this.state.token} user={this.state.username} expires={this.state.expires} logout={this.logOut.bind(this)}/> : <Form change={this.passInput.bind(this)} submit={this.handleSubmit.bind(this)} user={this.state.username} pw={this.state.pw} error={this.state.error} /> }
      </div>
    )
  }
}

class LoginDetails extends React.Component {
  render() {
    return(
      <div>
        <p><span>Username:</span> {this.props.user}</p>
        <p><span>Token:</span> {this.props.token}</p>
        <p><span>Expires at:</span> {this.props.expires}</p>
        <button onClick={this.props.logout}>Logout</button>
        <AioClient server={this.props.server} />
      </div>
    )
  }
}

class Form extends React.Component {

  render() {
    return(
      <form onSubmit={this.props.submit}>
        <Username user={this.props.user} change={this.props.change}/>
        <Password pw={this.props.pw} change={this.props.change}/>
        <Submit submit={this.props.submit}/>
        <p id="error">{this.props.error}</p>
      </form>
    )
  }
}
<commit_msg>Remove expires props.<commit_after>import $ from 'jquery';
import React from 'react';
import AioClient from './aioclient';

export default class LoginComponent extends React.Component {
  constructor() {
    super();
    this.state = {
      loggedIn: false,
      username: '',
      pw: '',
      token: '',
      error: ''
    }
  }

    handleSubmit(e) {
        e.preventDefault()
        const data = { login: this.state.username, password: <PASSWORD> }

        $.ajax({
              url: this.props.url,
              type: "GET",
              success: function(data) {
                console.log("success")
                console.log(data)
                this.setState({
                    token: data.token,
                    loggedIn: true,
                    error: ''
                });
              }.bind(this),
            crossDomain: true,
            withCredentials: true,
            headers: {
                    'login': this.state.username,
                    'password': <PASSWORD>
                },
              error: function(xhr, status, err) {
                  console.log('error')
                  console.log(xhr);
                  console.log(status);
                  console.log(err);
                this.setState({
                    error: 'Login details not correct'
                });
              }.bind(this)
            });
  }

  logOut() {
  }

  passInput(state, e) {
    this.setState({
      [state]: e.target.value
    });
  }

  render() {
    return (
      <div>
        <h1>React Login</h1>
        { this.state.loggedIn ? <LoginDetails server={this.props.server} token={<PASSWORD>.state.token} user={this.state.username} logout={this.logOut.bind(this)}/> : <Form change={this.passInput.bind(this)} submit={this.handleSubmit.bind(this)} user={this.state.username} pw={this.state.pw} error={this.state.error} /> }
      </div>
    )
  }
}

class LoginDetails extends React.Component {
  render() {
    return(
      <div>
        <p><span>Username:</span> {this.props.user}</p>
        <p><span>Token:</span> {this.props.token}</p>
        <button onClick={this.props.logout}>Logout</button>
        <AioClient server={this.props.server} />
      </div>
    )
  }
}

class Form extends React.Component {

  render() {
    return(
      <form onSubmit={this.props.submit}>
        <Username user={this.props.user} change={this.props.change}/>
        <Password pw={this.props.pw} change={this.props.change}/>
        <Submit submit={this.props.submit}/>
        <p id="error">{this.props.error}</p>
      </form>
    )
  }
}

{'fraction_non_alphanumeric': 0.1553347280334728, 'fraction_numerical': 0.000697350069735007, 'mean_word_length': 1.6646539712029726, 'pattern_counts': {'":': 0, '<': 64, '<?xml version=': 0, '>': 64, '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': '7034919', 'n_tokens_mistral': 1717, 'n_tokens_neox': 1675, 'n_words': 293}