Giter Club home page Giter Club logo

mongoose-user-management's Introduction

mongoose-user-management

This library provides API to register , authenticate and manage the user for a typical wesite. This stores the data in Mongodb. Mongoose is used as ODM. Rightnow , its has three implemented methods

1)register 2)Autheticate 3)resetPassword

User schema is as Below

{

    email: {
        type: String,
        lowercase: true,
        trim: true,
        index: true,
        unique: true,
        required: true
    },

    username: {
        type: String,
        lowercase: true,
        trim: true,
        index: true,
        unique: true,
        required: true
    },

    password: {
        type: String,
        required: true,
        bcrypt: true
    },

    firstName: {
        type: String,
        trim: true
    },

    lastName: {
        type: String,
        trim: true
    },

    middleName: {
        type: String,
        trim: true
    },

    identificationNumber: {
        type: String,
        bcrypt: true,
        trim: true
    },

    phoneNumber1: {
        type: String,
        trim: true
    },

    phoneNumber2: {
        type: String,
        trim: true
    },

    address: {

        address1:{
            type: String,
            trim: true

            },
        address2:{
            type: String,
            trim: true

        },
        zip:{
            type: String,
            trim: true

        },
        state:{
            type: String,
            trim: true

        },
        city:{
            type: String,
            trim: true

        },
        country:{
            type: String,
            trim: true

        }

         

    }

}

Sample code is as below

const user=require('mongoose-user-management')
const mongoose = require('mongoose');

let fakeuser=let fake={
            email:"[email protected]",
            username:"test",
            password:"sddada",
            firstName: "Manish",
            lastName: "Ranjan",
            middleName:"mi",
            identificationNumber:"55555",
            phoneNumber1:"5555555",
            phoneNumber2:"ffffffffffff",
            address:{
                address1:"101 Metlife Way",
                address2:"Test way",
                zip:"27513",
                state:"NC",
                city:"Cary",
                country:"USA"
            }
}

(async function(){

await mongoose.connect("mongodb://localhost:27017/mydb", { useNewUrlParser: true }); 
    mongoose.connection
        .once('open', () => console.log('Connected!'))
        .on('error', (error) => {
            console.warn('Error : ',error);
        });


user.register(fake)
})();

mongoose-user-management's People

Contributors

bit-warrior avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Forkers

wannesvermeire

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.