fiuser

0.0.0 • Public • Published

FIuser module

based on nodejs

Why use fiuser?

when we dev sth web, we have to face the login signup singout

why we must konw how cookie and session work?

even if we may just need one admin user

so I think login module should be separate from our program.

let me totally manage your user.

How to use?

var FIuser = require('fiuser'); // constructor

var user = new FIuser({
	redirect: '/home',
	prepath: '/sign',
	key: 'admin',
	timeout: 2*24*60*60*1000
});

http.createServer(function(req,res){
	var pathname = url.parse(req.url).pathname;
	if(pathname.indexOf(user.prepath) === 0) {
		user.manage(req,res);
	} else {
		res.end("Home");	
	}		
}).listen(80);

Example:

if given a url http://localhost/signin(can be anyurl match '/sign' and not signout or signup)

fiuser will check cookie,if pass,redirect

else,given a login page.

if given a logout http://localhost/signout

fiuser will clear cookie

if given a signup http://localhost/signup

fiuser will give a signup page

and if done, redirect to the redirect uri

The Default Options:

title: 'Login', // title in form view
description: 'Powedby fiuser', // description in form view
theme: 'default', // form view theme
redirect: '/home', // redirect when finish
key: 'admin', // a key help to gen md5
prepath: '/sign', // important! module will agent all path match prepath
timeout: 24*60*60*1000, // cookie timeout
remember_me: 7*24*60*60*1000 // timeout if remember_me is on 

TODO

  • more themes

  • html template

  • signup

Readme

Keywords

none

Package Sidebar

Install

npm i fiuser

Weekly Downloads

0

Version

0.0.0

License

BSD

Last publish

Collaborators

  • ftft1885