diff --git a/config/env/development.js b/config/env/development.js
index 1b56e5411d..df4f2a3813 100644
--- a/config/env/development.js
+++ b/config/env/development.js
@@ -44,6 +44,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',
diff --git a/config/env/production.js b/config/env/production.js
index a02ec40c50..fac8462980 100644
--- a/config/env/production.js
+++ b/config/env/production.js
@@ -44,6 +44,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: {
diff --git a/config/env/test.js b/config/env/test.js
index de57686f00..34c6ba8553 100644
--- a/config/env/test.js
+++ b/config/env/test.js
@@ -37,6 +37,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: {
diff --git a/modules/users/client/img/buttons/paypal.png b/modules/users/client/img/buttons/paypal.png
new file mode 100644
index 0000000000..5468939563
Binary files /dev/null and b/modules/users/client/img/buttons/paypal.png differ
diff --git a/modules/users/client/views/authentication/authentication.client.view.html b/modules/users/client/views/authentication/authentication.client.view.html
index 3f67964d3c..b5e422ea47 100644
--- a/modules/users/client/views/authentication/authentication.client.view.html
+++ b/modules/users/client/views/authentication/authentication.client.view.html
@@ -16,6 +16,9 @@
Sign in using your social accounts
+
+
+
diff --git a/modules/users/client/views/settings/manage-social-accounts.client.view.html b/modules/users/client/views/settings/manage-social-accounts.client.view.html
index b40b203e6c..6a0b47300e 100644
--- a/modules/users/client/views/settings/manage-social-accounts.client.view.html
+++ b/modules/users/client/views/settings/manage-social-accounts.client.view.html
@@ -40,5 +40,11 @@
+
diff --git a/modules/users/server/config/strategies/paypal.js b/modules/users/server/config/strategies/paypal.js
new file mode 100644
index 0000000000..21271bf975
--- /dev/null
+++ b/modules/users/server/config/strategies/paypal.js
@@ -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);
+ }
+ ));
+};
diff --git a/modules/users/server/routes/auth.server.routes.js b/modules/users/server/routes/auth.server.routes.js
index 6390beed5f..02b6471847 100644
--- a/modules/users/server/routes/auth.server.routes.js
+++ b/modules/users/server/routes/auth.server.routes.js
@@ -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'));
};
diff --git a/package.json b/package.json
index d7cd927b1e..4487b15c00 100644
--- a/package.json
+++ b/package.json
@@ -43,6 +43,7 @@
"passport": "~0.2.2",
"passport-facebook": "^2.0.0",
"passport-github": "~0.1.5",
+ "passport-paypal-openidconnect": "^0.1.1",
"passport-google-oauth": "~0.2.0",
"passport-linkedin": "~0.1.3",
"passport-local": "^1.0.0",