Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 3b91827

Browse files
WardormeurDanielBrierton
authored andcommitted
Check oauth profile call is given a token (#216)
1 parent a763363 commit 3b91827

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

oauth2.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -171,22 +171,26 @@ module.exports = function (options) {
171171
}
172172

173173
function cmd_profile (args, done) {
174-
_getUserForAccessToken(args.access_token, function (err, user) {
175-
if (err) return done(null, {error: err, http$: {status: 500}});
176-
var profile = {
177-
id: user.id,
178-
name: user.name,
179-
email: user.email,
180-
isAdmin: _.contains(user.roles, 'cdf-admin'),
181-
isChampion: user.isChampion,
182-
isYouthOver13: user.isYouthOver13,
183-
isMentor: user.isMentor,
184-
isParent: user.isParent,
185-
isVerified: user.isVerified,
186-
profileId: user.profileId
187-
};
188-
return done(null, profile);
189-
});
174+
if (args.token) {
175+
_getUserForAccessToken(args.access_token, function (err, user) {
176+
if (err) return done(null, {error: err, http$: {status: 500}});
177+
var profile = {
178+
id: user.id,
179+
name: user.name,
180+
email: user.email,
181+
isAdmin: _.contains(user.roles, 'cdf-admin'),
182+
isChampion: user.isChampion,
183+
isYouthOver13: user.isYouthOver13,
184+
isMentor: user.isMentor,
185+
isParent: user.isParent,
186+
isVerified: user.isVerified,
187+
profileId: user.profileId
188+
};
189+
return done(null, profile);
190+
});
191+
} else {
192+
return done(null, {error: 'Please provide a token', http$: {status: 422}});
193+
}
190194
}
191195

192196
return {

0 commit comments

Comments
 (0)