mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-08-04 22:40:10 +02:00
PayPal Authentication
This commit is contained in:
6
config/env/development.js
vendored
6
config/env/development.js
vendored
@@ -29,6 +29,12 @@ module.exports = {
|
||||
clientID: process.env.GITHUB_ID || 'APP_ID',
|
||||
clientSecret: process.env.GITHUB_SECRET || 'APP_SECRET',
|
||||
callbackURL: '/api/auth/github/callback'
|
||||
},
|
||||
paypal: {
|
||||
clientID: process.env.PAYPAL_ID || 'CLIENT_ID',
|
||||
clientSecret: process.env.PAYPAL_SECRET || 'CLIENT_SECRET',
|
||||
callbackURL: '/api/auth/paypal/callback',
|
||||
sandbox: true
|
||||
},
|
||||
mailer: {
|
||||
from: process.env.MAILER_FROM || 'MAILER_FROM',
|
||||
|
||||
6
config/env/production.js
vendored
6
config/env/production.js
vendored
@@ -27,6 +27,12 @@ module.exports = {
|
||||
clientSecret: process.env.GITHUB_SECRET || 'APP_SECRET',
|
||||
callbackURL: '/api/auth/github/callback'
|
||||
},
|
||||
paypal: {
|
||||
clientID: process.env.PAYPAL_ID || 'CLIENT_ID',
|
||||
clientSecret: process.env.PAYPAL_SECRET || 'CLIENT_SECRET',
|
||||
callbackURL: '/api/auth/paypal/callback',
|
||||
sandbox: false
|
||||
},
|
||||
mailer: {
|
||||
from: process.env.MAILER_FROM || 'MAILER_FROM',
|
||||
options: {
|
||||
|
||||
6
config/env/test.js
vendored
6
config/env/test.js
vendored
@@ -31,6 +31,12 @@ module.exports = {
|
||||
clientSecret: process.env.GITHUB_SECRET || 'APP_SECRET',
|
||||
callbackURL: '/api/auth/github/callback'
|
||||
},
|
||||
paypal: {
|
||||
clientID: process.env.PAYPAL_ID || 'CLIENT_ID',
|
||||
clientSecret: process.env.PAYPAL_SECRET || 'CLIENT_SECRET',
|
||||
callbackURL: '/api/auth/paypal/callback',
|
||||
sandbox: true
|
||||
},
|
||||
mailer: {
|
||||
from: process.env.MAILER_FROM || 'MAILER_FROM',
|
||||
options: {
|
||||
|
||||
BIN
modules/users/client/img/buttons/paypal.png
Normal file
BIN
modules/users/client/img/buttons/paypal.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.1 KiB |
@@ -16,6 +16,9 @@
|
||||
<a href="/api/auth/github" target="_self" class="undecorated-link">
|
||||
<img src="/modules/users/img/buttons/github.png">
|
||||
</a>
|
||||
<a href="/api/auth/paypal" target="_self" class="undecorated-link">
|
||||
<img src="/modules/users/img/buttons/paypal.png">
|
||||
</a>
|
||||
</div>
|
||||
<div ui-view></div>
|
||||
</section>
|
||||
|
||||
@@ -40,5 +40,11 @@
|
||||
<i class="glyphicon glyphicon-plus"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="social-account-container" data-ng-hide="isConnectedSocialAccount('paypal')">
|
||||
<img ng-src="/modules/users/img/buttons/paypal.png">
|
||||
<a class="btn btn-success btn-remove-account" href="/api/auth/paypal" target="_self">
|
||||
<i class="glyphicon glyphicon-plus"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
42
modules/users/server/config/strategies/paypal.js
Normal file
42
modules/users/server/config/strategies/paypal.js
Normal file
@@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
var passport = require('passport'),
|
||||
PayPalStrategy = require('passport-paypal-openidconnect').Strategy,
|
||||
users = require('../../controllers/users.server.controller');
|
||||
|
||||
module.exports = function (config) {
|
||||
passport.use(new PayPalStrategy({
|
||||
clientID: config.paypal.clientID,
|
||||
clientSecret: config.paypal.clientSecret,
|
||||
callbackURL: config.paypal.callbackURL,
|
||||
scope: 'openid profile email',
|
||||
sandbox: config.paypal.sandbox,
|
||||
passReqToCallback: true
|
||||
|
||||
},
|
||||
function(req, accessToken, refreshToken, profile, done) {
|
||||
// Set the provider data and include tokens
|
||||
var providerData = profile._json;
|
||||
providerData.accessToken = accessToken;
|
||||
providerData.refreshToken = refreshToken;
|
||||
|
||||
// Create the user OAuth profile
|
||||
var providerUserProfile = {
|
||||
firstName: profile.name.givenName,
|
||||
lastName: profile.name.familyName,
|
||||
displayName: profile.displayName,
|
||||
email: profile._json.email,
|
||||
username: profile.username,
|
||||
provider: 'paypal',
|
||||
providerIdentifierField: 'user_id',
|
||||
providerData: providerData
|
||||
};
|
||||
|
||||
// Save the user OAuth profile
|
||||
users.saveOAuthUserProfile(req, providerUserProfile, done);
|
||||
}
|
||||
));
|
||||
};
|
||||
@@ -50,4 +50,8 @@ module.exports = function(app) {
|
||||
// Setting the github oauth routes
|
||||
app.route('/api/auth/github').get(passport.authenticate('github'));
|
||||
app.route('/api/auth/github/callback').get(users.oauthCallback('github'));
|
||||
|
||||
// Setting the paypal oauth routes
|
||||
app.route('/api/auth/paypal').get(passport.authenticate('paypal'));
|
||||
app.route('/api/auth/paypal/callback').get(users.oauthCallback('paypal'));
|
||||
};
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
"passport-linkedin": "~0.1.3",
|
||||
"passport-google-oauth": "~0.1.5",
|
||||
"passport-github": "~0.1.5",
|
||||
"passport-paypal-openidconnect": "^0.1.1",
|
||||
"acl": "~0.4.4",
|
||||
"socket.io": "~1.1.0",
|
||||
"lodash": "~2.4.1",
|
||||
|
||||
Reference in New Issue
Block a user