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

Implements user invite #3

Merged
merged 2 commits into from
Sep 3, 2017
Merged

Implements user invite #3

merged 2 commits into from
Sep 3, 2017

Conversation

dolftax
Copy link

@dolftax dolftax commented Sep 2, 2017

After token verification, trigger user creation has to be done from front-end after user fills in username and password.

Say if user b wants to invite user a. user b generates a token for user a with email [email protected] and sends it along. user a makes a call with email [email protected] and a invite token and gets his own email in response. Then show a page for user to set username and password and .. ..

Copy link
Contributor

@kaustavdm kaustavdm left a comment

Choose a reason for hiding this comment

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

Looks good. One nitpick: Split routing logic for /user/invite to POST /user/invite and GET /user/invite/verify, instead of switching over action

@kaustavdm
Copy link
Contributor

Also, you need to:

  • respond using a set format:
    res.status(200).json({
      msg: 'User invite created',
      status: 200,
      payload: {
         token: inviteToken,
         email: recipientEmail,
         sender: senderUserID
    }})
  • handle promise rejection. Do a .catch(next)

/**
* Verifies invite token
*/
router.post('/invite/verify', requiredFields(['invite_token', 'email']), (req, res, next) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Make this GET, not creating anything new here

* Generates invite token
*/
router.post('/invite', requiredFields(['user_id', 'email']), (req, res, next) => {
return jwt.createInviteJWT(req.required.user_id, req.required.email, req.app.get('jwtsecret'))
Copy link
Contributor

Choose a reason for hiding this comment

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

You are returning a promise. You need to write send out response instead. See comment

/**
* Generates invite token
*/
router.post('/invite', requiredFields(['user_id', 'email']), (req, res, next) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Make user_id camelCase userID for uniformity.

@kaustavdm kaustavdm merged commit 8ab2c82 into master Sep 3, 2017
@kaustavdm
Copy link
Contributor

Thanks @dolftax. Take a potato.

@dolftax dolftax deleted the user-invite branch September 3, 2017 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants