Skip to content
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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Login #68

wants to merge 10 commits into from

Conversation

alaabadra
Copy link
Collaborator

No description provided.

})
.then(res=>res.json())
.then(({msg}) => {
this.setState({msg:'login successfully'});
Copy link

@tomduggan85 tomduggan85 Apr 23, 2019

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.

@@ -0,0 +1,6 @@
const router = require('express').Router();
const { validation } = require('../middleware/validation.js');

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();

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.

Copy link
Collaborator Author

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

Copy link

@tomduggan85 tomduggan85 Apr 24, 2019

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();
}
});
}

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.

Copy link
Collaborator Author

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;

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');
Copy link
Collaborator

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');
Copy link
Collaborator

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');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const error = new TypeError('error in building database');
const error = new Error('error in building database');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants