loki-local-passport
is a custom strategy that simplifies authenticating with Passport using id and password.
This strategy use persistent in-memory JavaScript Datastore - LokiJS instead of large NoSQL DB like a MongoDB what give for us amazing performance.
Intro
This module give your posibility quickly handle user auth without painfull dev work like configuration and other stuff. Everything what you need is 3 line. Three line Carl! You will say but why i need it? It's a simple answer : Imagine that your are at hackaton and make a prototype of your app. Where you will spend more time in auth module or at the logic of your future startup (I hope you do).
Also this module will be helpfull in a
- petty projects
- university projects
- non-production projects and even more.
Installation
npm install passport-local-passport
Usage
As every passport strategy this one need:
- body-parser
- cookie-parser
- express-session
- and also connect-flash for send flash messages to user
Install this packadges by command :
npm i express express-session passport body-parser cookie-parser connect-flash
require them and use:
Require all this stuff needed for passport:
const passport = ; const bodyParser = ;const cookieParser = ;const session = ;const flash = ; app;app;app;app;app;app;
Require installed module (LokiLocal)
const LokiLocal = ;
Add the middleware function LokiLokal.use() to your routes. Example:
app; app;
That`s all what you need to start use it.
If you want control what is going on your can add to middleware LokiLokal.use() object with debug mode. Example:
app; app;
It will print in console all actions.
All of this fields can be placed in your signup form (if not it will have value custom):
- id required
- password required
- name
- surname
- number
- sex
- age
- country
Example of simple app :
const express = ; const passport = ;const LokiLocal = ; const bodyParser = ;const cookieParser = ;const session = ;const flash = ; const app = ; app;app;app;app;app;app; app; app; app;