forked from t1msh/node-oauth20-provider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.js
83 lines (72 loc) · 2.24 KB
/
user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
var
error = require('./../error');
/**
* User schema is defined by server side logic
*/
/**
* Gets primary key of the user
*
* @param user {Object} User object
*/
module.exports.getId = function(user) {
throw new error.serverError('User model method "getId" is not implemented');
};
/**
* Fetches user object by primary key
* Should be implemented with server logic
*
* @param userId {String} Unique identifier
* @param cb {Function} Function callback ->(error, object)
*/
module.exports.fetchById = function(userId, cb) {
throw new error.serverError('User model method "fetchById" is not implemented');
};
/**
* Fetches user object by primary key
* Should be implemented with server logic
*
* @param username {String} Unique username/login
* @param cb {Function} Function callback ->(error, object)
*/
module.exports.fetchByUsername = function(username, cb) {
throw new error.serverError('User model method "fetchByUsername" is not implemented');
};
/**
* Checks password for the user
* Function arguments MAY be different
*
* @param user {Object} User object
* @param password {String} Password to be checked
* @param cb {Function} Function callback -> (error, boolean) If input is correct
*/
module.exports.checkPassword = function(user, password, cb) {
/**
* In case of sync check function use:
* (user.password == superHashFunction(password)) ? cb(null, true) : cb(null, false);
*/
throw new error.serverError('User model method "checkPassword" is not implemented');
};
/**
* Fetch user object from session (fetch logged user only)
*
* @param req
*/
module.exports.fetchFromRequest = function(req) {
throw new error.serverError('User model method "fetchFromRequest" is not implemented');
};
/**
* Check wheter or not the user already authorized the client.
* @param user {Object} User object
* @param client {Object} Client object that is requestion authorization
*/
module.exports.clientAuthorizationPref = function(user, client, cb) {
cb(null, false)
}
/**
* Save user authorization preference.
* @param user {Object} User object
* @param client {Object} Client object that is requestion authorization
*/
module.exports.saveClientAuthorizationPref = function(user, client, cb) {
cb(null)
}