Skip to content

Commit

Permalink
Merge pull request #10 from PixNyb/development
Browse files Browse the repository at this point in the history
Forgot to actually update the axios request in the oauth provider
  • Loading branch information
PixNyb authored Jul 6, 2024
2 parents 9b63d11 + 44d9c13 commit 91af3d0
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/providers/oauth2.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,20 @@ const oauth2Provider = (id, keyName) => ({
const userURL = process.env[`OAUTH2_${keyName}_USER_URL`];
const userField = process.env[`OAUTH2_${keyName}_USER_FIELD`] || "email"; // The field to use as the user identifier
if (userURL) {
axios.get(
axios.get(userURL,
{
url: userURL,
headers: {
Authorization: `Bearer ${accessToken}`,
"Authorization": `Bearer ${accessToken}`,
"User-Agent": "Request-Promise",
},
},
(error, response, body) => {
if (error) return done(error);

if (response.statusCode !== 200)
}).then((response) => {
if (response.status !== 200)
return done(
new Error(`Failed to fetch user profile: ${response.statusCode}`)
new Error(`Failed to fetch user profile: ${response.status}`)
);

try {
const user = JSON.parse(body);
const user = response.data;
return done(null, {
id: user[userField],
strategy: `oauth2_${id}`,
Expand All @@ -51,8 +47,9 @@ const oauth2Provider = (id, keyName) => ({
} catch {
return done(new Error("Failed to parse user profile"));
}
}
);
}).catch((error) => {
return done(error);
});
} else
return done(null, {
id: profile.id,
Expand Down

0 comments on commit 91af3d0

Please sign in to comment.