This repository has been archived by the owner on Jun 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 744
Use Your Own User Authorization
fengmk2 edited this page Jul 26, 2014
·
9 revisions
Every company has a private user authorization system inside. This document try to show you how to integrate custom user authorization service into cnpm.
cnpm user data structure is very simple, only required login
and email
fields, others is optional.
{
"login": "fengmk2",
"email": "fengmk2@gmail.com",
"name": "Yuan Feng",
"html_url": "http://fengmk2.github.com",
"avatar_url": "https://avatars3.githubusercontent.com/u/156269?s=460",
"im_url": "",
"site_admin": false
}
-
login
: login name, only allowa-zA-Z0-9
and_-.
characters -
email
: email address, e.g.: work email inside the company
-
name
: screen name show on the page, e.g.: full name or nick name -
html_url
: a url let other people know he/she more -
avatar_url
: avatar url, default is gavatar url base onemail
-
im_url
: Instant Messaging url, like WangWang, QQ, Weibo, Twitter, Facebook, GTalk -
site_admin
: admin of cnpm or not, default isfalse
function DefaultUserService() {}
var proto = DefaultUserService.prototype;
/**
* Auth user with login name and password
* @param {String} login login name
* @param {String} password login password
* @return {User}
*/
proto.auth = function* (login, password) {};
/**
* Get user by login name
* @param {String} login login name
* @return {User}
*/
proto.get = function* (login) {};
/**
* List users
* @param {Array<String>} logins login names
* @return {Array<User>}
*/
proto.list = function* (logins) {};
/**
* Search users
* @param {String} query query keyword
* @param {Object} [options] optional query params
* - {Number} limit match users count, default is `20`
* - {Number}
* @return {Array<User>}
*/
proto.search = function* (query, options) {};
Copyright @ 2013 - present cnpmjs.org