Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Allow only specific users to login using everyauth

Allow only specific users to login using everyauth


I have an expressjs app with Everyauth setup.

Everyauth is working fine. Now, I want everyauth to allow users to Login into the app whose email id matches a regular expression.

Say I want people to login whose email starts with the letter "foo" (suppose, [email protected]) or is of a specific domain like (suppose [email protected])

Kindly provide me some solution to solve this situation

Problem courtesy of: ArjunUrs


If you use password authentication (which I presume cause otherwise you don't have to care about e-mail addresses) then you can use the validateRegistration function.

For others, write a piece of connect middleware like:

function checkEmail(regex){
  return function (req, res, next) {
      // get everyauth.user via the everyauth helper
      if (! {
          res.end("e-mail address not allowed");
      else { next(); }

And use it right after the everyauth use like:

connect // or express
Solution courtesy of: Jan Jongboom


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Allow only specific users to login using everyauth


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription