Skip to content

Commit

Permalink
fix(dashboard): fix microsoft scope checking
Browse files Browse the repository at this point in the history
  • Loading branch information
Snazzah committed Dec 28, 2023
1 parent b1e9f21 commit 493af72
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/dashboard/pages/api/microsoft/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export default async (req: NextApiRequest, res: NextApiResponse) => {
return res.redirect(`/?error=${encodeURIComponent('Could not get an access token, please sign in again.')}&from=microsoft`);
if (!response.refresh_token || typeof response.refresh_token !== 'string')
return res.redirect(`/?error=${encodeURIComponent('Could not get a refresh token, please sign in again.')}&from=microsoft`);
if (response.scope !== scopes.filter((s) => s !== 'offline_access').join(' ')) return res.redirect(`/?error=invalid_scope&from=microsoft`);
const scopesRecieved = response.scope.split(' ');
if (scopes.find((s) => s !== 'offline_access' && !scopesRecieved.includes(s))) return res.redirect(`/?error=invalid_scope&from=microsoft`);

const me: MicrosoftUser = await fetch('https://graph.microsoft.com/v1.0/me', {
headers: { Authorization: `${response.token_type} ${response.access_token}` }
Expand Down

0 comments on commit 493af72

Please sign in to comment.