client/src/components/Login.js
changeset 94 2c2a9c8dc216
parent 90 990f2c928b15
child 129 d48946d164c6
equal deleted inserted replaced
93:469da13402e2 94:2c2a9c8dc216
    11   login = () => {
    11   login = () => {
    12     const username = this.username.value;
    12     const username = this.username.value;
    13     const password = this.password.value;
    13     const password = this.password.value;
    14 
    14 
    15     this.props.authActions.loginSubmit(username, password);
    15     this.props.authActions.loginSubmit(username, password);
       
    16   }
       
    17 
       
    18   submit = (e) => {
       
    19     e.preventDefault();
       
    20 
       
    21     this.login();
    16   }
    22   }
    17 
    23 
    18   onClickRegister = (e) => {
    24   onClickRegister = (e) => {
    19     e.preventDefault();
    25     e.preventDefault();
    20     this.props.history.push('/register');
    26     this.props.history.push('/register');
    54         <Navbar history={this.props.history} />
    60         <Navbar history={this.props.history} />
    55         <Grid fluid>
    61         <Grid fluid>
    56           <Row>
    62           <Row>
    57             <Col md={6} mdOffset={3}>
    63             <Col md={6} mdOffset={3}>
    58               <Panel header={ panelHeader } className="panel-login">
    64               <Panel header={ panelHeader } className="panel-login">
    59                 <form>
    65                 <form onSubmit={this.submit}>
    60                   <FormGroup validationState={ errorMessages && errorMessages.has('username') ? 'error' : null }>
    66                   <FormGroup validationState={ errorMessages && errorMessages.has('username') ? 'error' : null }>
    61                     <ControlLabel>Username</ControlLabel>
    67                     <ControlLabel>Username</ControlLabel>
    62                     <FormControl componentClass="input" type="text" inputRef={ref => { this.username = ref; }} />
    68                     <FormControl componentClass="input" type="text" inputRef={ref => { this.username = ref; }} />
    63                     { this.renderErrorMessage(errorMessages, 'username') }
    69                     { this.renderErrorMessage(errorMessages, 'username') }
    64                   </FormGroup>
    70                   </FormGroup>
    66                     <ControlLabel>Password</ControlLabel>
    72                     <ControlLabel>Password</ControlLabel>
    67                     <FormControl componentClass="input" type="password" inputRef={ref => { this.password = ref; }} />
    73                     <FormControl componentClass="input" type="password" inputRef={ref => { this.password = ref; }} />
    68                     { this.renderErrorMessage(errorMessages, 'password') }
    74                     { this.renderErrorMessage(errorMessages, 'password') }
    69                   </FormGroup>
    75                   </FormGroup>
    70                   { this.renderNonFieldErrors(errorMessages) }
    76                   { this.renderNonFieldErrors(errorMessages) }
    71                   <Button block bsStyle="primary" onClick={this.login}>Login</Button>
    77                   <Button type="submit" block bsStyle="primary" onClick={this.login}>Login</Button>
    72                 </form>
    78                 </form>
    73               </Panel>
    79               </Panel>
    74               <p className="text-center">
    80               <p className="text-center">
    75                 <a className="text-muted" href="/register" onClick={ this.onClickRegister }>Not registered yet? Create an account.</a>
    81                 <a className="text-muted" href="/register" onClick={ this.onClickRegister }>Not registered yet? Create an account.</a>
    76               </p>
    82               </p>