freeCodeCamp icon indicating copy to clipboard operation
freeCodeCamp copied to clipboard

fix(learn): advanced-node-and-express username field

Open Xavier-Pierre-dev opened this issue 3 years ago • 16 comments
trafficstars

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 main branch 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

Xavier-Pierre-dev avatar Aug 22 '22 01:08 Xavier-Pierre-dev

gitpod-io[bot] avatar Aug 22 '22 01:08 gitpod-io[bot]

:eyes: Review this PR in a CodeSee Review Map

View the CodeSee Map of this change

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map Legend

ghost avatar Aug 22 '22 01:08 ghost

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 avatar Aug 23 '22 17:08 Xavier-Pierre-dev

@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.

hanswang123456 avatar Aug 23 '22 18:08 hanswang123456

Also check out issue https://github.com/freeCodeCamp/freeCodeCamp/issues/47109. Might be a nice issue for you to attempt.

hanswang123456 avatar Aug 23 '22 18:08 hanswang123456

@ShaunSHamilton let's review this and do any additional tasks. This has been sitting here for a while.

raisedadead avatar Oct 07 '22 06:10 raisedadead

To mention, this is related to: https://github.com/freeCodeCamp/freeCodeCamp/issues/39599

ShaunSHamilton avatar Oct 07 '22 12:10 ShaunSHamilton

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>

ShaunSHamilton avatar Oct 07 '22 17:10 ShaunSHamilton

Once we are production ready

Do you want to target Monday afternoon your time? I can have a deployment good to go around then.

raisedadead avatar Oct 07 '22 17:10 raisedadead

Do you want to target Monday afternoon your time?

Yes, that suits me.

ShaunSHamilton avatar Oct 07 '22 17:10 ShaunSHamilton

It's a date. You are paying for my beer.

raisedadead avatar Oct 07 '22 17:10 raisedadead

Do you want to target Monday afternoon your time?

Was that yesterday?

majestic-owl448 avatar Oct 11 '22 15:10 majestic-owl448

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.

raisedadead avatar Oct 11 '22 15:10 raisedadead

Heya @moT01 is this still blocked? Or can we go ahead and get this in?

naomi-lgbt avatar Oct 28 '22 22:10 naomi-lgbt

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.

raisedadead avatar Oct 29 '22 06:10 raisedadead

Are we at the point I should add the solutions to this PR?

ShaunSHamilton avatar Oct 29 '22 09:10 ShaunSHamilton

I think this is actually blocked until https://github.com/freeCodeCamp/boilerplate-advancednode/pull/25 lands?

naomi-lgbt avatar Oct 31 '22 23:10 naomi-lgbt

No, this needs to get in first, and once it hits production - we can merge that PR @naomi-lgbt.

moT01 avatar Nov 01 '22 00:11 moT01

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.

Xavier-Pierre-dev avatar Nov 08 '22 17:11 Xavier-Pierre-dev