new oauth2 server
This commit is contained in:
parent
1b15b4f3b7
commit
23aaf61b70
28
library.js
28
library.js
@ -49,7 +49,7 @@
|
||||
const constants = Object.freeze({
|
||||
type: 'oauth2', // Either 'oauth' or 'oauth2'
|
||||
name: 'icynet', // Something unique to your OAuth provider in lowercase, like "github", or "nodebb"
|
||||
scope: 'email privilege',
|
||||
scope: 'email image privileges',
|
||||
oauth: {
|
||||
requestTokenURL: '',
|
||||
accessTokenURL: '',
|
||||
@ -58,12 +58,12 @@
|
||||
consumerSecret: nconf.get('oauth:secret'), // don't change this line
|
||||
},
|
||||
oauth2: {
|
||||
authorizationURL: nconf.get('oauth:provider') + '/oauth2/authorize',
|
||||
tokenURL: nconf.get('oauth:provider') + '/oauth2/token',
|
||||
authorizationURL: 'https://secure.icynet.eu/oauth2/authorize',
|
||||
tokenURL: 'https://secure.icynet.eu/oauth2/token',
|
||||
clientID: nconf.get('oauth:id'),
|
||||
clientSecret: nconf.get('oauth:secret'),
|
||||
},
|
||||
userRoute: nconf.get('oauth:provider') + '/oauth2/user'
|
||||
userRoute: 'https://api.icynet.eu/api/user'
|
||||
})
|
||||
|
||||
const OAuth = {};
|
||||
@ -169,26 +169,12 @@
|
||||
};
|
||||
|
||||
OAuth.parseUserReturn = function (data, callback) {
|
||||
// Alter this section to include whatever data is necessary
|
||||
// NodeBB *requires* the following: id, displayName, emails.
|
||||
// Everything else is optional.
|
||||
|
||||
// Find out what is available by uncommenting this line:
|
||||
// console.log(data);
|
||||
|
||||
var profile = {};
|
||||
profile.id = data.id;
|
||||
profile.id = data.uuid;
|
||||
profile.displayName = data.display_name;
|
||||
profile.emails = [{ value: data.email }];
|
||||
profile.isAdmin = data.privilege === 5;
|
||||
profile.picture = 'https://icynet.eu/api/avatar/' + data.id
|
||||
|
||||
// Do you want to automatically make somebody an admin? This line might help you do that...
|
||||
// profile.isAdmin = data.isAdmin ? true : false;
|
||||
|
||||
// Delete or comment out the next TWO (2) lines when you are ready to proceed
|
||||
//process.stdout.write('===\nAt this point, you\'ll need to customise the above section to id, displayName, and emails into the "profile" object.\n===');
|
||||
//return callback(new Error('Congrats! So far so good -- please see server log for details'));
|
||||
profile.isAdmin = (data.privileges || []).includes('admin');
|
||||
profile.picture = data.picture;
|
||||
|
||||
// eslint-disable-next-line
|
||||
callback(null, profile);
|
||||
|
Loading…
Reference in New Issue
Block a user