Skip to content
This repository has been archived by the owner on May 28, 2018. It is now read-only.

Commit

Permalink
Validate user on click in login form
Browse files Browse the repository at this point in the history
  • Loading branch information
nbrohee committed Nov 15, 2016
1 parent 4fa612e commit 5d51048
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions client/src/components/login/LoginPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React, { PropTypes } from 'react'
import LoginForm from './LoginForm'
import Validation from '../common/Validation'
import {userValidationConstraints} from './userValidationConstraints'
import toastr from 'toastr'
import {isEmptyObject} from '../common/validationHelper'

export class LoginPage extends React.Component {
constructor(props, context) {
Expand All @@ -28,6 +30,14 @@ export class LoginPage extends React.Component {

loginUser(event) {
event.preventDefault()
const errors = this.userValidation.validateAllFields(this.state.user)
if (!isEmptyObject(errors)) {
this.setState({ errors })
toastr.error('Tu dois renseigner un email et un mot de passe valides')
}
else {
//TODO perform authent
}
}

validateUserField(field, value) {
Expand Down

0 comments on commit 5d51048

Please sign in to comment.