Conversation
| }) | ||
| .then(res=>res.json()) | ||
| .then(({msg}) => { | ||
| this.setState({msg:'login successfully'}); |
There was a problem hiding this comment.
@alaabadra You could redirect the user to a different page here (after a short timeout) if you'd like.
You can use react-router-dom's withRouter to have this.props.history injected into your component, and then you could call this.props.history.push('/home') or something like that.
server/controller/index.js
Outdated
| @@ -0,0 +1,6 @@ | |||
| const router = require('express').Router(); | |||
| const { validation } = require('../middleware/validation.js'); | |||
There was a problem hiding this comment.
@alaabadra It looks like validation.js is exporting a function called isFound, not validation - one of these files might need a change in their function name.
|
|
||
| if (!resultIsFound) { | ||
| console.log('not register'); | ||
| res.end(); |
There was a problem hiding this comment.
@alaabadra This could return a 401.
There was a problem hiding this comment.
ok, thank you for this comment ,but this not final push only i want feedback
There was a problem hiding this comment.
Ah ok! that makes sense. Sometimes in my own PRs, I write that in the description (something like "this is not finished yet, but I'm looking for feedback") to help set the expectations for the people reviewing my code.
| res.end(); | ||
| } | ||
| }); | ||
| } |
There was a problem hiding this comment.
@alaabadra you could add an else here and return a 401.
There was a problem hiding this comment.
ok , thank you for this comment
| onSubmit = event => { | ||
| event.preventDefault(); | ||
| this.setState({emailValue: event.target.email.value,passwordValue: event.target.password.value}); | ||
| const {emailValue,passwordValue}=this.state; |
There was a problem hiding this comment.
@alaabadra You could use event.target.email.value and event.target.password.value in your fetch instead of storing them in state right here (line 13) and then immediately getting them back out of state (line 14).
React can sometimes batch up state changes, as a performance optimization, which means that sometimes if you call setState and then on the next line call getState (or call a function on the next line which then calls setState), your new state might not yet be in this.state, so you can sometimes see bugs that come from things like that.
| const hashPassword = (password) => { | ||
| bcrypt.hash(password, 5).then(hashedPassword => console.log(hashedPassword)); | ||
| }; | ||
| hashPassword('11111'); |
There was a problem hiding this comment.
hashPassword 111111 ?
| @@ -0,0 +1,6 @@ | |||
| const bcrypt = require('bcryptjs'); | |||
There was a problem hiding this comment.
use bcrypt instead of bcryptjs
| const path = require('path'); | ||
| const connect = require('./connection.js'); | ||
|
|
||
| const error = new TypeError('error in building database'); |
There was a problem hiding this comment.
| const error = new TypeError('error in building database'); | |
| const error = new Error('error in building database'); |
No description provided.