-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Login #68
base: master
Are you sure you want to change the base?
Conversation
}) | ||
.then(res=>res.json()) | ||
.then(({msg}) => { | ||
this.setState({msg:'login successfully'}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alaabadra This could return a 401.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, thank you for this comment ,but this not final push only i want feedback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alaabadra you could add an else
here and return a 401.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hashPassword 111111 ?
@@ -0,0 +1,6 @@ | |||
const bcrypt = require('bcryptjs'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const error = new TypeError('error in building database'); | |
const error = new Error('error in building database'); |
No description provided.