npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

loginregisternodejs

v1.0.4

Published

this is a simple register and login with the bcrypt

Readme

Register-login-nodeJs

This is a simple but powerfull login register with nodejs. And using the bcrypt to in crypt the password.

Install

For installation you need to install from the terminal in place where you project is.

npm install loginregisternodejs

Explanations

The files are:

schema.js

All the magic for the Back-End is done there.

There i have the schema creator, find for the mongodb and the hash function for encrypt. The password and for check the password if is the correct.

bcrypt

Install the bcrypt

npm install --save bcrypt

so you can hash the password.

First you need to make the schema for you insert in the mongodb the username and the password. So ypu need to install to help us the mongoose

npm install --save mongoose

var Schema = mongoose.Schema;

var login = new Schema({

    username: String,
    password: String
});

//here make the model
var userinsert =  mongoose.model('usersinsert', login);


And now we need to hashOutput to insert hash the password. First we require: var SchemaLogin = require('./model/schema'); In the app.js:

app.post('/register', function (req, res, next) {

    var myPassword = req.body.password;
    var userName = req.body.username;

    SchemaLogin.hashOutput(myPassword,userName);


    res.send('<p>ok</p>' );

});

Next we need to hash our password:

 var hashOutput = function hash(myPassword, username) {
    bcrypt.hash(myPassword, saltRounds, function(err, hash) {
        // Store hash in your password DB on mongodb.
        var UsersInsert = userinsert({
            username : username,
            password : hash
        });
        UsersInsert.save(function (err) {
            if (err) throw err;
            console.log('person login validation '+ UsersInsert.username +' save');
        });
    });

};

And to check the hash password:

 var check = function (myPassword, hash) {
     bcrypt.compare(myPassword, hash, function(err, res) {
         // res == true
         console.log('check is :'+ res);

     });
     return true;
 };

And in the app.js we can check the password if it Matches: With a login.

app.post('/login',function (req, res, next) {
//    here i we make the check for the password
    var myPassword = req.body.password;
    var userName = req.body.username;
    
    
    SchemaLogin.userinsert.find({"username": userName}, function (err, obj) {
        if (err) throw err;
        // object of all the users
        console.log(obj[0].password);
        var hashFromdb = obj[0].password;
        var isTrue = SchemaLogin.check(myPassword, hashFromdb);
        
        if(isTrue) {
            res.send('<p>The password has been check ok. you are the </p>');
        }else {
            res.send('<p>The password is wronk</p>');
        }
    next();
    });



});