auth-config.js
2.34 KB
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
'use strict';
const passport = require('passport');
const WeixinStrategy = require('passport-weixin');
const SinaStrategy = require('passport-sina').Strategy;
const QQStrategy = require('passport-qq').Strategy;
const DoubanStrategy = require('passport-douban').Strategy;
const RenrenStrategy = require('passport-renren').Strategy;
const AlipayStrategy = require('../passport/models/passport-alipay').Strategy;
const config = global.yoho.config;
let siteUrl = config.siteUrl.indexOf('//') === 0 ? 'http:' + config.siteUrl : config.siteUrl;
/**
* wechat登录
*/
passport.use('home-wechat', new WeixinStrategy({
clientID: config.thirdLogin.wechat.appID,
clientSecret: config.thirdLogin.wechat.appSecret,
callbackURL: `${siteUrl}/home/bind/wechat/callback`,
requireState: true,
scope: 'snsapi_login'
}, (accessToken, refreshToken, profile, done) => {
done(null, profile);
}));
// sina 登录
passport.use('home-sina', new SinaStrategy({
clientID: config.thirdLogin.sina.appID,
clientSecret: config.thirdLogin.sina.appSecret,
callbackURL: `${siteUrl}/home/bind/sina/callback`,
requireState: false
}, (accessToken, refreshToken, profile, done) => {
done(null, profile);
}));
// qq 登录
passport.use('home-qq', new QQStrategy({
clientID: config.thirdLogin.qq.appID,
clientSecret: config.thirdLogin.qq.appSecret,
callbackURL: `${siteUrl}/home/bind/qq/callback`,
requireState: false
}, (accessToken, refreshToken, profile, done) => {
done(null, profile);
}));
// alipay 登录
passport.use('home-alipay', new AlipayStrategy({
partner: config.thirdLogin.alipay.appID,
key: config.thirdLogin.alipay.appSecret,
return_url: `${siteUrl}/home/bind/alipay/callback`
}, (profile, done) => {
done(null, profile);
}));
// douban 登录
passport.use('douban', new DoubanStrategy({
clientID: config.thirdLogin.douban.appID,
clientSecret: config.thirdLogin.douban.appSecret,
callbackURL: `${siteUrl}/passport/autosign/doubanback`
}, (accessToken, refreshToken, profile, done) => {
done(null, profile);
}));
// renren 登录
passport.use('home-renren', new RenrenStrategy({
clientID: config.thirdLogin.renren.appID,
clientSecret: config.thirdLogin.renren.appSecret,
callbackURL: `${siteUrl}/home/bind/renren/callback`
}, (accessToken, refreshToken, profile, done) => {
done(null, profile);
}));