freeCodeCamp
freeCodeCamp copied to clipboard
fix(learn): advanced-node-and-express username field
Checklist:
- [x] I have read freeCodeCamp's contribution guidelines.
- [x] My pull request has a descriptive title (not a vague title like
Update index.md) - [x] My pull request targets the
mainbranch of freeCodeCamp. - [x] I have tested these changes either locally on my machine, or GitPod.
Closes #XXXXX
I notice that for the moment the curriculum have a little coherency issue starting at github authentication. In reality at the start of the project we set up our strategy with the username property for example when we register an user using the form the curriculum will push us to use :
app.route('/register')
.post((req, res, next) => {
myDataBase.findOne({ username: req.body.username }, function(err, user) {
if (err) {
next(err);
} else if (user) {
res.redirect('/');
} else {
myDataBase.insertOne({
username: req.body.username,
password: req.body.password
},
(err, doc) => {
if (err) {
res.redirect('/');
} else {
// The inserted document is held within
// the ops property of the doc
next(null, doc.ops[0]);
}
}
)
}
})
},
passport.authenticate('local', { failureRedirect: '/' }),
(req, res, next) => {
res.redirect('/profile');
}
);
As you can see we use username: req.body.username then we also use that to display content on profile.pug. In reality username property are use since start until the github authentication. In fact for github authentication username property are not set up so later with socket we use name instead of username this lead to an issue where if we login with something else than github the name will be undefined for the chat app and not be displayed.
This is why I propose some change inside the curriculum in order to add the username property when a user use github in order to register himself and edit the next step so the challenge guideline will push the learner to use the username instead of the user. To make it properly work either it's with simple register form, login with or without github
Sorry I make a mistake with that : Xavier-Pierre-dev requested review from hanswang123456 and removed request for ShaunSHamilton 8 minutes ago
It wasn't intentional, I clicked by mistake, this is my first PR.
@Xavier-Pierre-dev Please get @ShaunSHamilton, @Sboonny, or @moT01 to review as they are actual reviewers. I'm just looking out for any small fixes.
Also check out issue https://github.com/freeCodeCamp/freeCodeCamp/issues/47109. Might be a nice issue for you to attempt.
@ShaunSHamilton let's review this and do any additional tasks. This has been sitting here for a while.
To mention, this is related to: https://github.com/freeCodeCamp/freeCodeCamp/issues/39599
This is ready to go in. Once we are production ready, we need to have the Gists updated based off of mine here: https://gist.github.com/ShaunSHamilton
Also, the boilerplate needs updating: <insert_pr_once_made>
Once we are production ready
Do you want to target Monday afternoon your time? I can have a deployment good to go around then.
Do you want to target Monday afternoon your time?
Yes, that suits me.
It's a date. You are paying for my beer.
Do you want to target Monday afternoon your time?
Was that yesterday?
Was that yesterday?
Yes - we met, but we could not get this in. Also, we decided that this needs review from others. We will talk about this in the dev-team catch-up meeting.
Heya @moT01 is this still blocked? Or can we go ahead and get this in?
can we go ahead and get this in?
I believe as soon as the helper solutions are ready on the guide we are good to go.
Are we at the point I should add the solutions to this PR?
I think this is actually blocked until https://github.com/freeCodeCamp/boilerplate-advancednode/pull/25 lands?
No, this needs to get in first, and once it hits production - we can merge that PR @naomi-lgbt.
Sorry I wasn't able to see all of the avancement on this PR before today.
I also wanted to thanks @moT01, @ShaunSHamilton, @scissorsneedfoodtoo and all the contributors.
