Skip to content

Enhance email verification doc #321

Closed

Description

@ebarault

URL of the page

https://loopback.io/doc/en/lb2/Registering-users.html#verifying-email-addresses
https://loopback.io/doc/en/lb3/Registering-users.html#verifying-email-addresses

Nature of the issue

In order to keep track of a discussion with @jsheely and @emazzu on gitter: the doc should be enhanced regarding the usage of the user.verify() method.

People who are not aware of this quite recent feature could keep validating the user's email by using a temp AccessToken instance token, as in the resetPassword listener. This draws a security risk as such a token could be used to perform Rest requests.

Making the doc more complete on this part will help preventing developers from implementing the wrong scenario.

Activity

  1. crandmck commented on Mar 15, 2017

    @crandmck
    Contributor

    Thanks @ebarault can you please provide some references for this new feature? Or some other info that we can use to write the doc? An example is always a good start :-)

  2. ebarault commented on Mar 17, 2017

    @ebarault
    ContributorAuthor

    Actually i helped a couple of developers in gitter by going through the code in user.js... 😕
    here are some excerpts:

    Missing in the doc (raw wording)
    user.verify() method generates a token that is directly attached to the user instance itself. Using such a token is required rather than creating some custom logic relying on a AccessToken instance belonging to the user, as using the latter represents a security risk: this type of token allows to perform any rest requests authorized to the user.
    (should be wrapped in a warning or important alert)

    The example already referenced in the doc this is a good starting point.

    the following section shows a couple of additional info

    Missing in the doc (which features an example with jade templates)
    In case the user is using the jade template proposed in the example for the verify page, then the following lines should be added in app.js, this is missing in the doc.

    // configure view handler
    app.set('view engine', 'ejs');
    app.set('views', path.join(__dirname, 'views'));
    

    Also a /verified view/page+route should be created in the context of this example.
    A route should accordingly be created by adding this to the app.js

    app.get('/verified', function(req, res) {
      res.render('verified');
    });
    

    @bajtos : side note: considering that the default template references the verify.ejs template here shouldn't a project bootstrapped with the cli already have these lines in app.js + the verify.ejs / verified.ejs templates + a default redirect route pointing the /verified, making the feature really available OOTB?

    Missing in the doc
    The template for the verify page can be customized using the template option, see https://github.com/strongloop/loopback/blob/master/common/models/user.js#L414

    In order to customize the verification mail sent: a templateFn option is available, see strongloop/loopback#2937

  3. crandmck commented on Mar 17, 2017

    @crandmck
    Contributor

    OK, thanks for the info. I'll work on adding this asap. Unfortunately, I'm overbooked with other work atm... If you want to tackle docs, that would be great. Otherwise, I'll get to it as time permits.

    Thanks again.

  4. bajtos commented on Mar 20, 2017

    @bajtos
    Member

    considering that the default template references the verify.ejs template here shouldn't a project bootstrapped with the cli already have these lines in app.js + the verify.ejs / verified.ejs templates + a default redirect route pointing the /verified, making the feature really available OOTB?

    That would be great!

  5. dhmlau commented on Apr 26, 2022

    @dhmlau
    Member

    Since LoopBack 3 has reached end-of-life, closing this issue.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions