<commit_before>import React, { Component } from 'react';
import dismissKeyboard from 'react-native-dismiss-keyboard'
import {
  AsyncStorage,
  View,
  Image,
  TouchableWithoutFeedback
} from 'react-native'
import { Grid, Col } from 'react-native-easy-grid'
import {
  StyleProvider,
  Form,
  Item,
  Label, Text,
  Input,
  Button,
  Container
} from 'native-base'

import { loginUser, registerUser } from '../api'
import variables from '../theme/variables/platform'

export default class LoginForm extends Component {
  static navigationOptions = {
    header: { visible: false }
  }
  state = {
    itsc: '',
    password: '',
    error: ''
  }

  submitLogin = () => {
    // IF login fail than try to register, if still fail than that means user used wrong password
    fetch(`https://api.usthing.xyz/Directory/api.php?itsc=${this.state.itsc}`).then(response => response.json())
    .then(result => {
      if (result.success) {
        this.setState({ error: '' })
      loginUser({ itsc: this.state.itsc, password: <PASSWORD> }).then(({success, token}) => {
        if (success) {
          AsyncStorage.setItem('Authorization', token).then(() => {
            AsyncStorage.setItem('itsc', this.state.itsc).then(() => this.props.onLogin(token, this.state.itsc))
          })
        } else {
          registerUser({ itsc: this.state.itsc, password: <PASSWORD> }).then(({success, token}) => {
            if (success) {
              AsyncStorage.setItem('Authorization', token).then(() => {
                AsyncStorage.setItem('itsc', this.state.itsc).then(() => this.props.onLogin(token, this.state.itsc))
              })
            }<commit_msg>add wrong password message<commit_after>import React, { Component } from 'react';
import dismissKeyboard from 'react-native-dismiss-keyboard'
import {
  AsyncStorage,
  View,
  Image,
  TouchableWithoutFeedback
} from 'react-native'
import { Grid, Col } from 'react-native-easy-grid'
import {
  StyleProvider,
  Form,
  Item,
  Label, Text,
  Input,
  Button,
  Container
} from 'native-base'

import { loginUser, registerUser } from '../api'
import variables from '../theme/variables/platform'

export default class LoginForm extends Component {
  static navigationOptions = {
    header: { visible: false }
  }
  state = {
    itsc: '',
    password: '',
    error: ''
  }

  submitLogin = () => {
    // IF login fail than try to register, if still fail than that means user used wrong password
    fetch(`https://api.usthing.xyz/Directory/api.php?itsc=${this.state.itsc}`).then(response => response.json())
    .then(result => {
      if (result.success) {
        this.setState({ error: '' })
      loginUser({ itsc: this.state.itsc, password: <PASSWORD> }).then(({success, token}) => {
        if (success) {
          AsyncStorage.setItem('Authorization', token).then(() => {
            AsyncStorage.setItem('itsc', this.state.itsc).then(() => this.props.onLogin(token, this.state.itsc))
          })
        } else {
          registerUser({ itsc: this.state.itsc, password: <PASSWORD> }).then(({success, token}) => {
            if (success) {
              AsyncStorage.setItem('Authorization', token).then(() => {
                AsyncStorage.setItem('itsc', this.state.itsc).then(() => this.props.onLogin(token, this.state.itsc))
              })
            } else {
              this.setState({ error: 'Wrong password' })
            }
{'fraction_non_alphanumeric': 0.15362063910876575, 'fraction_numerical': 0.0, 'mean_word_length': 2.8122905027932963, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 25, 'https://': 2, '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': '6682359', 'n_tokens_mistral': 1013, 'n_tokens_neox': 1012, 'n_words': 232}