Advertisement
Guest User

Untitled

a guest
Sep 17th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react';
  2. import './style.css';
  3. import './login.css'
  4. var unirest = require('unirest');
  5.  
  6.  
  7. class Login extends Component {
  8.  
  9.   renderUserMessage(){
  10.  
  11.       if (window.location.search === "?failed=1") {
  12.         return (
  13.           <div class="alert alert-info" role="alert">
  14.               <strong>Try Again!</strong> Your username or password is not quite correct.
  15.           </div>
  16.         );
  17.       } else {
  18.         return (
  19.         <div></div>
  20.         );
  21.       }
  22.     }
  23.  
  24.   constructor(props) {
  25.      super(props);
  26.  
  27.      this.state = {
  28.         userName: '',
  29.         password: '',
  30.  
  31.      }
  32.  
  33.      this.updateStateuserName.userName = this.updateStateuserName.bind(this);
  34.      this.updateStatepassword.password = this.updateStatepassword.bind(this);
  35.  
  36.   };
  37.  
  38.   updateStateuserName(e) {
  39.      this.setState({userName: e.target.value});
  40.   }
  41.   updateStatepassword(e) {
  42.      this.setState({password: e.target.value});
  43.   }
  44.  
  45.   checkLogin(e) {
  46.    e.preventDefault();
  47.  
  48.  
  49.     var uName = this.state.userName
  50.     var uPass = this.state.password
  51.  
  52. console.log(uName);
  53. console.log(uPass);
  54.  
  55. unirest.post('http://grwh.work:3001/api/signin')
  56. .headers({'Accept': 'application/json', 'Content-Type': 'application/json'})
  57. .send({ "email": "snxraven@gmail.com", "password": "jonn22" })
  58. .end(function (response) {
  59.   console.log(response.body);
  60. });
  61.  
  62.  
  63.   //window.location.replace('/login?failed=1');
  64. }
  65.  
  66.   render() {
  67.  
  68.  
  69.   //  if (LoggedInChecker != "True"){
  70.   return (
  71.        <div>
  72.  
  73.            <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" />
  74.            <div className="container">
  75.              <div className="wrapper">
  76.                <form action="/home" method="post" name="Login_Form" className="form-signin" onSubmit={this.checkLogin.bind(this)}>
  77.                  <div className="row text-center bol"><i className="fa fa-circle" /></div>
  78.                  <h3 className="form-signin-heading text-center">
  79.                    Venue Manager <br /> Developer Version 1.0 {this.props.params}<br />
  80.                  </h3>
  81.                  <hr className="spartan" />
  82.                  <div className="input-group">
  83.                    <span className="input-group-addon" id="sizing-addon1">
  84.                      <i className="fa fa-user" />
  85.                    </span>
  86.                    <input type="text" className="form-control input-md" name="Username" placeholder="Username" value = {this.state.userName}
  87.               onChange = {this.updateStateuserName.userName} required autofocus />
  88.  
  89.  
  90.  
  91.                  </div>
  92.                  <div className="input-group">
  93.                    <span className="input-group-addon" id="sizing-addon1">
  94.                      <i className="fa fa-lock" />
  95.                    </span>
  96.                    <input type="password" className="form-control" name="Password" placeholder="Password" value = {this.state.password}
  97.               onChange = {this.updateStatepassword.password} required />
  98.  
  99.  
  100.                  </div>
  101.                  <button  className="btn btn-lg btn-primary btn-block" name="Submit" value="true" type="Submit">Submit</button>
  102.                 <div> <center> { this.renderUserMessage() } </center></div>
  103.  
  104.  
  105.  
  106.                </form>
  107.  
  108.              </div>
  109.            </div>
  110.          </div>
  111.  
  112.  
  113.  
  114.      );
  115.   //}
  116. }
  117. }
  118. export default Login;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement