-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassport.js
More file actions
31 lines (26 loc) · 860 Bytes
/
passport.js
File metadata and controls
31 lines (26 loc) · 860 Bytes
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
const passport = require('passport');
const IdentificatorStrategy = require('passport-identificator').Strategy;
const cfg = require("./cfg");
passport.use(new IdentificatorStrategy(
{
"identificatorHost": cfg.identificatorHost,
"callbackURL": cfg.host+"/login/callback",
},
(profile, cb) => {
cb(null, profile.id);
}
));
passport.serializeUser((profile, cb) => {
return cb(null, profile);
});
passport.deserializeUser((id, cb) => {
IdentificatorStrategy.loadUserProfile(cfg.identificatorHost, id, cb);
});
module.exports = passport;
module.exports.loadUserProfile = function(id) {
return new Promise((res, rej) => {
require('passport-identificator').Strategy.loadUserProfile(require.main.require('./cfg').identificatorHost, id, (err, profile) => {
res(profile);
});
});
}