GithubHelp home page GithubHelp logo

node-email-verification's Introduction

Node Email Verification

Build Status Gitter

NPM

Verify user signup over email with NodeJS and MongoDB!

The way this works is as follows:

  • temporary user is created with a randomly generated URL assigned to it and then saved to a MongoDB collection
  • email is sent to the email address the user signed up with
  • when the URL is accessed, the user's data is transferred to the real collection

A temporary user document has a TTL of 24 hours by default, but this (as well as many other things) can be configured. See the options section for more details. It is also possible to resend the verification email if needed.

Installation

via npm:

npm install email-verification

Quick Example/Guide

Before you start, make sure you have a directory structure like so:

app/
-- userModel.js
-- tempUserModel.js
node_modules/
server.js

Step 1: Add your dependencies

All of the code in this section takes place in server.js. Note that mongoose has to be passed as an argument when requiring the module:

var User = require('./app/userModel'),
    mongoose = require('mongoose'),
    nev = require('email-verification')(mongoose);
mongoose.connect('mongodb://localhost/YOUR_DB');

Step 2: Configure your settings

Next, make sure to configure the options (see the section below for more extensive detail on this):

nev.configure({
    verificationURL: 'http://myawesomewebsite.com/email-verification/${URL}',
    persistentUserModel: User,
    tempUserCollection: 'myawesomewebsite_tempusers',

    transportOptions: {
        service: 'Gmail',
        auth: {
            user: '[email protected]',
            pass: 'mysupersecretpassword'
        }
    },
    verifyMailOptions: {
        from: 'Do Not Reply <[email protected]>',
        subject: 'Please confirm account',
        html: 'Click the following link to confirm your account:</p><p>${URL}</p>',
        text: 'Please confirm your account by clicking the following link: ${URL}'
    }
}, function(error, options){
});

Note: Any options not included in the object you pass will take on the default value specified in the section below. Calling configure multiple times with new options will simply change the previously defined options.

Step 3: Create a Temporary user Model

To create a temporary user model, you can either generate it using a built-in function, or you can predefine it in a separate file. If you are pre-defining it, it must be IDENTICAL to the user model with an extra field for the URL; the default one is GENERATED_VERIFYING_URL: String.

// configuration options go here...

// generating the model, pass the User model defined earlier
nev.generateTempUserModel(User);

// using a predefined file
var TempUser = require('./app/tempUserModel');
nev.configure({
    tempUserModel: TempUser
}, function(error, options){
});

Step 4: Create a TempUser Model in your Signup Handler

Then, create an instance of the User model, and then pass it as well as a custom callback to createTempUser. Inside your createTempUser callback, make a call to the sendVerificationEmail function.

// get the credentials from request parameters or something
var email = "...",
    password = "...";

var newUser = User({
    email: email,
    password: password
});

nev.createTempUser(newUser, function(err, existingPersistentUser, newTempUser) {
    // some sort of error
    if (err)
        // handle error...

    // user already exists in persistent collection...
    if (existingPersistentUser)
        // handle user's existence... violently.

    // a new user
    if (newTempUser) {
        var URL = newTempUser[nev.options.URLFieldName];
        nev.sendVerificationEmail(email, URL, function(err, info) {
            if (err)
                // handle error...

            // flash message of success
        });

    // user already exists in temporary collection...
    } else {
        // flash message of failure...
    }
});

Step 4.5: Hash your users password

Note: An email will be sent to the email address that the user signed up with. If you are interested in hashing the password (which you probably should be), all you need to do is set the option hashingFunction to a function that takes the parameters password, tempUserData, insertTempUser, callback and returns insertTempUser(hash, tempUserData, callback), e.g.:

// sync version of hashing function
var myHasher = function(password, tempUserData, insertTempUser, callback) {
  var hash = bcrypt.hashSync(password, bcrypt.genSaltSync(8), null);
  return insertTempUser(hash, tempUserData, callback);
};

// async version of hashing function
myHasher = function(password, tempUserData, insertTempUser, callback) {
  bcrypt.genSalt(8, function(err, salt) {
    bcrypt.hash(password, salt, function(err, hash) {
      return insertTempUser(hash, tempUserData, callback);
    });
  });
};

Step 5: Confirm your user and save your user to persistent storage

To move a user from the temporary storage to 'persistent' storage (e.g. when they actually access the URL we sent them), we call confirmTempUser, which takes the URL as well as a callback with two parameters: an error, and the instance of the User model (or null if there are any errors, or if the user wasn't found - i.e. their data expired).

If you want to send a confirmation email, note that in your options the shouldSendConfirmation default value is true, which means that on calling confirmTempUser you will automatically send a confirmation e-mail. Creating a call to sendConfirmationEmail will end up sending two confirmation e-mails to the user. In your configurations, you should either have shouldSendConfirmation equal true or use sendConfirmationEmail.

If shouldSendConfirmation is false and you want to send a confirmation email, you need to make a call to the sendConfirmationEmail function, inside the confirmTempUser callback, which takes two parameters: the user's email and a callback. This callback takes two parameters: an error if any occured, and the information returned by Nodemailer.

var url = '...';
nev.confirmTempUser(url, function(err, user) {
    if (err)
        // handle error...

    // user was found!
    if (user) {
        // optional
        nev.sendConfirmationEmail(user['email_field_name'], function(err, info) {
            // redirect to their profile...
        });
    }

    // user's data probably expired...
    else
        // redirect to sign-up
});

Step 5.5: Allow user to resend verification email

If you want the user to be able to request another verification email, simply call resendVerificationEmail, which takes the user's email address and a callback with two parameters: an error, and a boolean representing whether or not the user was found.

var email = '...';
nev.resendVerificationEmail(email, function(err, userFound) {
    if (err)
        // handle error...

    if (userFound)
        // email has been sent
    else
        // flash message of failure...
});

To see a fully functioning example that uses Express as the backend, check out the examples section.

NEV supports Bluebird's PromisifyAll! Check out the examples section for that too.

API

configure(optionsToConfigure, callback(err, options))

Changes the default configuration by passing an object of options to configure (optionsToConfigure); see the section below for a list of all options. options will be the result of the configuration, with the default values specified below if they were not given. If there are no errors, err is null.

generateTempUserModel(UserModel, callback(err, tempUserModel))

Generates a Mongoose Model for the temporary user based off of UserModel, the persistent user model. The temporary model is essentially a duplicate of the persistent model except that it has the field {GENERATED_VERIFYING_URL: String} for the randomly generated URL by default (the field name can be changed in the options). If the persistent model has the field createdAt, then an expiration time (expires) is added to it with a default value of 24 hours; otherwise, the field is created as such:

{
    ...
    createdAt: {
        type: Date,
        expires: 86400,
        default: Date.now
    }
    ...
}

tempUserModel is the Mongoose model that is created for the temporary user. If there are no errors, err is null.

Note that createdAt will not be transferred to persistent storage (yet?).

createTempUser(user, callback(err, newTempUser))

Attempts to create an instance of a temporary user model based off of an instance of a persistent user, user, and add it to the temporary collection. newTempUser is the temporary user instance if the user doesn't exist in the temporary collection, or null otherwise. If there are no errors, err is null.

If a temporary user model hasn't yet been defined (generated or otherwise), err will NOT be null.

sendVerificationEmail(email, url, callback(err, info))

Sends a verification email to to the email provided, with a link to the URL to verify the account. If sending the email succeeds, then err will be null and info will be some value. See Nodemailer's documentation for information.

confirmTempUser(url, callback(err, newPersistentUser))

Transfers a temporary user (found by url) from the temporary collection to the persistent collection and removes the URL assigned with the user. newPersistentUser is the persistent user instance if the user has been successfully transferred (i.e. the user accessed URL before expiration) and null otherwise; this can be used for redirection and what not. If there are no errors, err is null.

sendConfirmationEmail(email, callback(err, info))

Sends a confirmation email to to the email provided. If sending the email succeeds, then err will be null and info will be some value. See Nodemailer's documentation for information.

resendVerificationEmail(email, callback(err, userFound))

Resends the verification email to a user, given their email. userFound is true if the user has been found in the temporary collection (i.e. their data hasn't expired yet) and false otherwise. If there are no errors, err is null.

Options

Here are the default options:

var options = {
    verificationURL: 'http://example.com/email-verification/${URL}',
    URLLength: 48,

    // mongo-stuff
    persistentUserModel: null,
    tempUserModel: null,
    tempUserCollection: 'temporary_users',
    emailFieldName: 'email',
    passwordFieldName: 'password',
    URLFieldName: 'GENERATED_VERIFYING_URL',
    expirationTime: 86400,

    // emailing options
    transportOptions: {
        service: 'Gmail',
        auth: {
            user: '[email protected]',
            pass: 'password'
        }
    },
    verifyMailOptions: {
        from: 'Do Not Reply <[email protected]>',
        subject: 'Confirm your account',
        html: '<p>Please verify your account by clicking <a href="${URL}">this link</a>. If you are unable to do so, copy and ' +
                'paste the following link into your browser:</p><p>${URL}</p>',
        text: 'Please verify your account by clicking the following link, or by copying and pasting it into your browser: ${URL}'
    },
    shouldSendConfirmation: true,
    confirmMailOptions: {
        from: 'Do Not Reply <[email protected]>',
        subject: 'Successfully verified!',
        html: '<p>Your account has been successfully verified.</p>',
        text: 'Your account has been successfully verified.'
    },

    hashingFunction: null,
}
  • verificationURL: the URL for the user to click to verify their account. ${URL} determines where the randomly generated part of the URL goes, and is needed. Required.

  • URLLength: the length of the randomly-generated string. Must be a positive integer. Required.

  • persistentUserModel: the Mongoose Model for the persistent user.

  • tempUserModel: the Mongoose Model for the temporary user. you can generate the model by using generateTempUserModel and passing it the persistent User model you have defined, or you can define your own model in a separate file and pass it as an option in configure instead.

  • tempUserCollection: the name of the MongoDB collection for temporary users.

  • emailFieldName: the field name for the user's email. If the field is nested within another object(s), use dot notation to access it, e.g. {local: {email: ...}} would use 'local.email'. Required.

  • passwordFieldName: the field name for the user's password. If the field is nested within another object(s), use dot notation to access it (see above). Required.

  • URLFieldName: the field name for the randomly-generated URL. Required.

  • expirationTime: the amount of time that the temporary user will be kept in collection, measured in seconds. Must be a positive integer. Required.

  • transportOptions: the options that will be passed to nodemailer.createTransport.

  • verifyMailOptions: the options that will be passed to nodemailer.createTransport({...}).sendMail when sending an email for verification. You must include ${URL} somewhere in the html and/or text fields to put the URL in these strings.

  • shouldSendConfirmation: send an email upon the user verifiying their account to notify them of verification.

  • confirmMailOptions: the options that will be passed to nodemailer.createTransport({...}).sendMail when sending an email to notify the user that their account has been verified. You must include ${URL} somewhere in the html and/or text fields to put the URL in these strings.

  • hashingFunction: the function that hashes passwords. Must take four parameters password, tempUserData, insertTempUser, callback and return insertTempUser(hash, tempUserData, callback).

Development

To beautify the code:

npm run format:main
npm run format:examples
npm run format:test
npm run format  # runs all

To lint the code (will error if there are any warnings):

npm run lint:main
npm run lint:examples
npm run lint:test
npm run lint  # runs all

To test:

npm test

Acknowledgements

thanks to Dakota St. Lauren for starting this project thanks to Frank Cash for looking over the code and adding tests.

license

ISC

node-email-verification's People

Contributors

charistheo avatar dakkers avatar franciscoknebel avatar gallyamb avatar joshbenz avatar maryum375 avatar melkir avatar webgardener avatar whitef0x0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-email-verification's Issues

user[options.emailFieldName] equates to undefined if email field is nested in another object

According to the docs:
emailFieldName: the field name for the user's email. If the field is nested within another object(s), use dot notation to access it, e.g. {local: {email: ...}} would use 'local.email'. Required.

but at line 230 of [index.js] in createTempUser function
query[options.emailFieldName] = user[options.emailFieldName];
user[options.emailFieldName] equates to undefined if email field is nested within another object.

This results in query not returning existing user with the same email and hence it tries to insert the user and unique constraint is violated.

createNewUser callback is never called

callback is never called, any idea on what could be causing this? Am I missing a setting?

   var newUser = new User({
      name: req.body.name,
      password: md5(req.body.password),
      email: req.body.email
    });

    nev.createTempUser(newUser, function(err, newTempUser) {
      if(newTempUser) {
        nev.registerTempUser(newTempUser, function(err) {
          res.json({sucess: true, message: 'An email has been sent for verification'});
        });
      } else {
        res.json({success: false, message: 'This username is awaiting verification, please check your email'});
      }
    });

SendGrid transport option

I want to implement my transport option with SendGrid but I have the following error :

Invalid login: 535 Authentication failed: Bad username / password

And my implementation is the following :

nev.configure({
  ....
  transportOptions: {
    service: 'SendGrid',
    auth: {
      api_key: config.mailer.key
    }
  },
  ....
}, function (err, options) {});

Is it possible to use a custom nodemailer-transport instead of configure it ?

Like this one https://github.com/sendgrid/nodemailer-sendgrid-transport
Here how it works
var mailer = nodemailer.createTransport(sgTransport(options));

TTL is broke

was working before, not sure why it's not working now. attempting to fix

@frankcash could you verify this by trying out the express example and changing the expiration time option to 60 seconds

add hapi example

I've been using HapiJS at work, and it's pretty simple, so I'm going to end up writing NEV for Hapi. hopefully it works the same...

Error sending confirmation mail: No recipients defined

Hi, I'm using your library and works fine for me except on the confirmation mail:

When I try to confirm to user that their verification mail has been confirmed the console returns me this error


Error: No recipients defined
    at SMTPConnection._formatError (D:\WebStorm\Alertame-Backend\node_modules\smtp-connection\src\smtp-connection.js:384:15)
    at SMTPConnection._setEnvelope (D:\WebStorm\Alertame-Backend\node_modules\smtp-connection\src\smtp-connection.js:566:30)
    at SMTPConnection.send (D:\WebStorm\Alertame-Backend\node_modules\smtp-connection\src\smtp-connection.js:270:10)
    at sendMessage (D:\WebStorm\Alertame-Backend\node_modules\nodemailer-smtp-transport\src\smtp-transport.js:118:20)
    at D:\WebStorm\Alertame-Backend\node_modules\nodemailer-smtp-transport\src\smtp-transport.js:157:17
    at SMTPConnection._actionAUTHComplete (D:\WebStorm\Alertame-Backend\node_modules\smtp-connection\src\smtp-connection.js:8
82:5)
    at SMTPConnection.<anonymous> (D:\WebStorm\Alertame-Backend\node_modules\smtp-connection\src\smtp-connection.js:239:22)
    at SMTPConnection._processResponse (D:\WebStorm\Alertame-Backend\node_modules\smtp-connection\src\smtp-connection.js:516:
16)
    at SMTPConnection._onData (D:\WebStorm\Alertame-Backend\node_modules\smtp-connection\src\smtp-connection.js:353:10)
    at emitOne (events.js:96:13)
    at TLSSocket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at TLSSocket.Readable.push (_stream_readable.js:134:10)
    at TLSWrap.onread (net.js:543:20)

This is the mailOptions passed to transporter.sendMail

{ from: 'Do Not Reply <[email protected]>',
  subject: 'Successfully verified!',
  html: '<p>Your account has been successfully verified.</p>',
  text: 'Your account has been successfully verified.',
  to: '[email protected]' }

What could be wrong? Thanks

error callback is not a function

Pls I need help to go round this error. It's evident that some had already encountered it. I've tried editing the index.js file. Yet no positive response still. I always get
return callback (null, options); //happens on line 154

TypeError: callback is not a function

NPM Package outdated

Ran into this issue with confirmation e-mail, which was receiving "true" as a callback function.
It was easily fixed on commit bb21779, but the NPM package is outdated and doesn't include that change.

Change docs on confirmTempUser

confirmTempUser checks your nev.options.shouldSendConfirmation, and if it is true, sends a confirmation message. The docs don't mention this, and suggest implementing a sendConfirmationEmail if you wish to send one. This will make the user receive two separate confirmation e-mails.

The docs should include that the user should choose to have shouldSendConfirmation on 'true' or (exclusive) use a sendConfirmationEmail to avoid this issue.

Update `package.json`

The package.json file now has misleading information. Needs to point to the correct repo. Also have updated contributors list.

API function to validate URL parameter

Hello,

First of all, excellent job, your library is really useful.

We need public route to verify the account and receive the token(generated url) to validate the account. I created a html page and Im receiving the url token by parameter, but I would like to validate the url token before consulting the validation rest service. Now Im using the "URLLength" option to validate it.
What you think about creating a new function just to validate the generated url token? If anyone discover the html verification route and try to use it wrongly( or hack), the page will be protected by the url validation.

Another issue:

nev.confirmTempUser(url, function(err, user) {
    if (err)
        // handle error...

    // user was found!
    if (user) {
        // optional
        nev.sendConfirmationEmail(user['email_field_name'], function(err, info) {
            // redirect to their profile...
        });
    }

    // user's data probably expired...
    else
        // redirect to sign-up
});

On the else (user's data probably expired) we need to check if user account is already verified, but I can't check it without the decryption of the url token to get the user email.
We need to test if the token is really expired or if user already verified the account, otherwise when user already verified the account and clicks again on the verification link it will say that token is expired and user could not verify the account..

Thank you,
Regards

Nested field for hashing password doesn't work

emailFieldName: the field name for the user's email. If the field is nested within another object(s), use dot notation to access it, e.g. {local: {email: ...}} would use 'local.email'. Required.
passwordFieldName: the field name for the user's password. If the field is nested within another object(s), use dot notation to access it (see above). Required.

It's doesn't work for me, I have "local.password" for my field passwordFieldName and in your insertTempUser (index.js) function you use
tempUserData[options.passwordFieldName] = password;
Which create a field "local.password : blabla" instead of "local : { password : blabla }" so I replaced this line with
tempUserData.local.password = password;
but it's not very flexible

mongoose version

Why are you using mongoose of 3.x version? There are already released v4.9.8

generateTempUserModel() doesn't inherit pre-save hooks

My temp user collection, which is generated with the nev.generateTempUserModel(User); command is not inheriting my pre-save mongoose hooks.

Short of creating a new mongoose schema for my temporary user collection is there anyway this can be fixe?

Not all fields copied

Hi, i have User table which have inner password and email fields, when created temp record i see next:
image

my user scheme is:

var userSchema = mongoose.Schema({
    local            : {
        email        : String,
        password     : String
    },
    facebook         : {
        id           : String,
        token        : String,
        email        : String,
        name         : String
    },
    twitter          : {
        id           : String,
        token        : String,
        displayName  : String,
        username     : String
    },
    google           : {
        id           : String,
        token        : String,
        email        : String,
        name         : String
    },
    
    name : String,
    created_date : Date,
    offical_channels : [{type: mongoose.Schema.Types.ObjectId, ref: 'Channel'}],
    private_channels : [{type: mongoose.Schema.Types.ObjectId, ref: 'Channel'}],
    private_pool_channels : [ChannelSchema]
});

Why not inserted local.password and local.email? How i can retrive email/password when user clicked on activation link, after user click i want to save new entry into primary table.

temporary user collection doesn't inherit pre-save hooks

My temp user collection, which is generated with the nev.generateTempUserModel(User); command is not inheriting my pre-save mongoose hooks.

Short of creating a new mongoose schema for my temporary user collection is there anyway this can be fixe?

CloudantDB

Can Cloudant be used in place of Mongodb?

rewrite some code

I don't know what drugs I was on when I wrote this thing but I really don't get why there's createTempUser and registerTempUser. will do this weekend (already in progress).

createTempUser's callback should have three params

createTempUser(newUser, callback( err, persistentUser, newTempUser)

the function already checks for the user being in the persistent collection. if there is a user, then newTempUser will just be null, but this is ambiguous, as newTempUser = null if the user isn't found in the temporary collection.

persistentUser should be null if the user is NOT found in the persistent collection. makes sense to me 🍤

TypeError: callback is not a function in index.js:153

I have the following error when I try to do the following code

var config = require('./config');
// import our User mongoose model
var User        = require('../app/models/user');

module.exports = function (nev) {

    nev.configure({
        verificationURL: 'http://localhost:8080/verification/${URL}',
        persistentUserModel: User,
        tempUserCollection: 'tmp_users',

        transportOptions: {
            service: 'SendGrid',
            auth: {
                api_key: config.mailer.key
            }
        },
        verifyMailOptions: {
            from: 'Do not reply <[email protected]>',
            subject: 'Please confirm account',
            html: 'Click the following link to confirm your account:</p><p>${URL}</p>',
            text: 'Please confirm your account by clicking the following link: ${URL}'
        }
    });

};
/home/melkir/WebstormProjects/appdatabase/node_modules/email-verification/index.js:153
    return callback(null, options);
           ^

TypeError: callback is not a function
    at Object.configure (/home/melkir/WebstormProjects/appdatabase/node_modules/email-verification/index.js:153:12)
    at module.exports (/home/melkir/WebstormProjects/appdatabase/config/mailer.js:7:9)
    at Object.<anonymous> (/home/melkir/WebstormProjects/appdatabase/server.js:27:27)

Do you know what can be the cause ?

support SQL

although MongoDB is definitely web-scale, it would be good to support SQL. I was thinking of using Sequelize to support all of the different kinds of SQL DBs buuuuut I know nothing about ORMs and if this is the place to use one.

cc @frankcash

write more tests

I noticed after submitting #26 that there weren't tests for checking for failures, e.g.

  • temp user has already signed up
  • temp user signed up but document expired (forcefully removed)
  • temp user confirmed account but tried to sign up again

will do this weekend!

Add unit tests

We need to add unit tests to make sure we don't break anything when iterating versions.

We should use the mocha library to accomplish this.

"Callback is not a function" upon sending confirmation email

Hello! I'm just checking in to report two instances of the error in the subject on the latest version.

The first time was just a minor issue where the callback for generateTempUserModel wasn't mentioned in the sample code in the readme, so adding it stopped the error. Step 3 in the readme uses no callback, but the API at the bottom does. That was my fault, so no worries.

Second time around was for the confirmation email and the trace showed node_modules/nodemailer-smtp-transport/lib/smtp-transport.js:141. I was able to get rid of the error by turning off the default option (shouldSendConfirmation: false) and then using the following without a callback nev.sendConfirmationEmail(newPersistentUser['email']); The API and step 5 both show a callback for the function. Did something perhaps change in nodemailer's end or am I forgetting something important?

Thanks for reading!

Temporary users does not delete on specified time for Ubuntu 16.04

On my laptop which has Ubuntu 14.04 the temporary users delete after the correct amount of time. But on my desktop which has Ubuntu 16.04 the delete time for temporary users does not work. I read on MongoDB's site that Ubuntu 16.04 is not fully supported yet. Is there a workaround for this in the mean time, instead of using the key value pair expirationTime: 'key in seconds'?

Feature to re-verify current users request to update email.

I'm looking at the API and wondering if there is a method to update an existing user's email and require double-opt in for that as well. Since this only touches the permanent user model and not the temporary one, will this require a new method such as nev.sendNewVerificationEmail(newEmail,oldEmail, url, callback(err,info))?

Deprecated packages

npm install warns of some deprecations we might want to take care of

npm WARN deprecated [email protected]: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue

These aren't issues with our code just the packages we're using.

getNestedValue undefined bug

Bug introduced on commit fe78efc.
The function getNestedValue changed from:

var i, len;
for (i = 0, path = path.split('.'), len = path.length; i < len; i++) 

to

for (let i = 0, path = path.split('.'), len = path.length; i < len; i++)

This change declares 3 lets, "i", "path" and "len". The problem with this is that path is already a defined variable, received as argument of the function, and used in the function.
To solve this problem, you need to either declare the variables "i" and "len" outside the for scope or split the path before the for scope.
I'll submit a pull request with this change later.

error on install

When I NPM I get the following error:

(node-gyp rebuild 2> builderror.log) || (exit 0)

I've tried some of the suggestions (deleting .node-gyp, making sure no instances of mongod are running) but still get the same error.

Validation error while creating generated user model

var userSchema = new mongoose.Schema({
    name: {
        first: {type: String, required: true, trim: true},
        last: {type: String, required: true, trim: true}
    },
    password: {type: String, select: false}
});

nev.generateTempUserModel(User)

var user = new User();
user.name.first = req.body.name.first;
user.name.last = req.body.name.last;

nev.createTempUser is throwing below validation error

ValidationError: temporary_users validation failed for name.first and name.last

Please let me know if this expected or error from my side

user will be added to temp collection if already in persistent collection

when a user verifies their account, their data is moved to the persistent collection. they can actually sign up again and be put into the temp collection again, and then when they try to access the new URL they were sent, MongoDB will throw an error (at least if the email field is set to be unique). will fix ASAP.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.