-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
41 lines (33 loc) · 1.32 KB
/
index.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
'use strict';
var VkontakteStrategy = require('passport-vkontakte').Strategy;
class Strategy extends VkontakteStrategy {
constructor(options, verify) {
super(options, verify);
this.name = 'token-vkontakte';
}
authenticate(req) {
const self = this;
this._loadUserProfile(req.query.access_token, function (err, profile) {
if (err) return self.fail();
function verified(err, user, info) {
if (err) return self.error(err);
if (!user) return self.fail(info);
self.success(user, info);
}
try {
if (self._passReqToCallback && self._verify.length == 6)
self._verify(req, req.query.access_token, null, params, profile, verified);
else if (self._passReqToCallback)
self._verify(req, req.query.access_token, null, profile, verified);
else if (self._verify.length == 5)
self._verify(req.query.access_token, null, params, profile, verified);
else
self._verify(req.query.access_token, null, profile, verified);
} catch (ex) {
return self.error(ex);
}
});
}
}
exports = module.exports = Strategy;
exports.Strategy = Strategy;