<commit_before>import React from 'react';
import { Link } from 'react-router-dom';
import SupportInformationDialog from './SupportInformationDialog';
import * as campus from '../CampusClient';
import TelegramLoginWidget from './TelegramLoginWidget';

class Login extends React.Component {
  state = {
    login: '',
    password: '',
    authFail: false,
    modal: false,
  };

  componentDidMount = async () => {
    if (!!(await campus.getCurrentUser())) {
      this.props.history.push('/home');
    }
  };

  setLogin = (event) => {
    this.setState({ login: event.target.value });
  };

  setPassword = (event) => {
    this.setState({ password: event.target.value });
  };

  authorize = async (e) => {
    e.preventDefault();

    const user = await campus.auth(this.state.login, this.state.password);
    await this.setState({ authFail: !user });

    if (!!user) {
      this.props.history.push(`/home`);
      window.location.reload();
    }
  };

  handleTelegramResponse = async (telegramResponse) => {
    const user = await campus.authViaTelegram(telegramResponse);

    await this.setState({ authFail: !user });

    if (!!user) {
      this.props.history.push(`/home`);
      window.location.reload();
    }
  };

  render = () => (
    <section>
      <div className="row">
        <div className="col-md-4" />
        <div className="col-md-4">
          <br />
          <div className="card">
            <div className="card-body">
              <div className="text-center">
                <a href="/">
                  {' '}
                  <img
                    src="/images/logo-big-green.png"
                    alt="Електроний кампус"
                    className="img-responsive logo-green"
                  />{' '}
                </a>
                <h2 className="text-center">Авторизацiя у системi</h2>
                <div className="panel-body">
                  <form>
                    <fieldset>
                      <div className="form-group">
                        <input
                          type="text"
                          value={this.state.login}
                          onChange={this.setLogin}
                          className="form-control"
													placeholder="Логін"
													autoComplete="current-username"
                        />
                      </div>

                      <div className="form-group">
                        <input
                          type="password"
                          value={this.state.password}
                          onChange={this.setPassword}
                          className="form-control"
													placeholder="<PASSWORD>"
													autoComplete="current-password"
                        />
                      </div>

                      {this.state.authFail && (
                        <div className="form-group">
                          <div className="alert alert-danger">
                            <button
                              type="button"
                              className="close"
                              onClick={() => this.setState({ authFail: false })}
                              data-dismiss="alert"
                              aria-hidden="true"
                            >
                              &times;
                            </button>
                            Перевірте корректність логіну та паролю.
                          </div>
                        </div>
                      )}<commit_msg>refactor(Login): add labels for screen-readers<commit_after>import React from 'react';
import { Link } from 'react-router-dom';
import SupportInformationDialog from './SupportInformationDialog';
import * as campus from '../CampusClient';
import TelegramLoginWidget from './TelegramLoginWidget';

class Login extends React.Component {
  state = {
    login: '',
    password: '',
    authFail: false,
    modal: false,
  };

  componentDidMount = async () => {
    if (!!(await campus.getCurrentUser())) {
      this.props.history.push('/home');
    }
  };

  setLogin = (event) => {
    this.setState({ login: event.target.value });
  };

  setPassword = (event) => {
    this.setState({ password: event.target.value });
  };

  authorize = async (e) => {
    e.preventDefault();

    const user = await campus.auth(this.state.login, this.state.password);
    await this.setState({ authFail: !user });

    if (!!user) {
      this.props.history.push(`/home`);
      window.location.reload();
    }
  };

  handleTelegramResponse = async (telegramResponse) => {
    const user = await campus.authViaTelegram(telegramResponse);

    await this.setState({ authFail: !user });

    if (!!user) {
      this.props.history.push(`/home`);
      window.location.reload();
    }
  };

  render = () => (
    <section>
      <div className="row">
        <div className="col-md-4" />
        <div className="col-md-4">
          <br />
          <div className="card">
            <div className="card-body">
              <div className="text-center">
                <a href="/">
                  {' '}
                  <img
                    src="/images/logo-big-green.png"
                    alt="Електроний кампус"
                    className="img-responsive logo-green"
                  />{' '}
                </a>
                <h2 className="text-center">Авторизацiя у системi</h2>
                <div className="panel-body">
                  <form>
                    <fieldset>
                      <div className="form-group">
                        <input
                          type="text"
                          value={this.state.login}
                          onChange={this.setLogin}
                          className="form-control"
                          placeholder="Логін"
                          aria-label="Логін"
                          autoComplete="current-username"
                        />
                      </div>

                      <div className="form-group">
                        <input
                          type="password"
                          value={this.state.password}
                          onChange={this.setPassword}
                          className="form-control"
                          placeholder="Пар<PASSWORD>"
                          aria-label="Пароль"
                          autoComplete="current-password"
                        />
                      </div>

                      {this.state.authFail && (
                        <div className="form-group">
                          <div className="alert alert-danger">
                            <button
                              type="button"
                              className="close"
                              onClick={() => this.setState({ authFail: false })}
                              data-dismiss="alert"
                              aria-hidden="true"
                            >
                              &times;
                            </button>
                            Перевірте корректність логіну та паролю.
                          </div>
                        </div>
                      )}
{'fraction_non_alphanumeric': 0.12246026261230131, 'fraction_numerical': 0.0011057360055286801, 'mean_word_length': 1.1703659268146371, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 75, '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': '7185750', 'n_tokens_mistral': 1860, 'n_tokens_neox': 1789, 'n_words': 318}