Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8016801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:39:07+00:00 2026-06-04T20:39:07+00:00

I want a Node.js service to authenticate the user of my website. How can

  • 0

I want a Node.js service to authenticate the user of my website. How can I do this?

I want to implement Everyauth authentication using the simple password method, not OpenID.

I tried https://github.com/jimpick/everyauth-example-password and it works.

I want to use the database to store. This script does not use a database. I have used MySQL in past so I prefer that but I am ok with anything else as well such as MongoDB.

I just want to add database to my script. Please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T20:39:08+00:00Added an answer on June 4, 2026 at 8:39 pm

    You only need to modify .authenticate method. Since connecting to database is (or should be) an asynchronous operation, then you need to add promise object (see everyauth documentation).

    Assuming you have some ORM with user data corresponding to user object with username and password attributes (in my example I’ll use mongoose engine), this is how it may look:

    .authenticate( function (login, password) {
        var promise = this.Promise(); /* setup promise object */
    
        /* asynchrnously connect to DB and retrieve the data for authentication */
        db.find({ username:login }, function(err, user) {
            if (err)
                return promise.fulfill([err]);
            if ((!user) || (user.password != password))
                return promise.fulfill(['Incorrect username or password!']);
            promise.fulfill(user);
        });
    
        return promise; /* return promise object */
    })
    

    I didn’t test it, but according to the documentation it should work. Remember that errors are supposed to be held in array.

    By the way: if you are using only the password method, then there is no need to, you know, use a cannon against a fly. 🙂 Writing your own (not necessarly perfect, but working) authentication mechanism is really simple and if you don’t know how to do this you should learn it. It will benefit in the future, because authentication and security in general are very important in every web app.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a simple smtp proxy using node.js, which receives mails and
I want to get to the exact node having this text: 'Company'. Once I
I just want to go up a parent node, so I can do a
I'm looking to build a RESTful API in node.js and want to authenticate users
I have a local web service which is using 60 running node.js servers. Now
I want to execute a JavaScript application on the server as a service. This
http://docs.blackberry.com/sampledata.json This is my web service and I want to parse and retrieve vehicleType,
I want to implement a Web Service whose purpose is to execute batch programs
Problem I want to be able to use Windows Authentication with Node.js. I understand
I have developed a simple Apache-Axis java web service using Eclipse IDE and now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.