Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic study detection when using feide login #991

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/web/src/components/organisms/Navbar/ProfileMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ const InnerProfileMenu = () => {
<Button
variant="subtle"
className={cn(navigationMenuTriggerStyle(), "hover:translate-y-0 active:translate-y-0")}
onClick={async () => signIn("auth0")}
onClick={async () => signIn("auth0", undefined, { connection: "FEIDE" })}
>
Log in
</Button>
<Button
variant="gradient"
className={cn(navigationMenuTriggerStyle(), "ml-3 hover:translate-y-0 active:translate-y-0")}
onClick={async () => signIn("auth0")}
onClick={async () => signIn("auth0", undefined, { connection: "FEIDE" })}
>
Sign up
</Button>
Expand Down
36 changes: 28 additions & 8 deletions infra/auth0/js/fetchUserProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,33 @@ function fetchUserProfile(accessToken, ctx, callback) {
} catch (jsonError) {
return callback(new Error(body));
}
const profile = {
user_id: bodyParsed.sub,
email: bodyParsed.email,
"email_verified": bodyParsed.email_verified,
"name": bodyParsed.name,
};
callback(null, profile);

request.get("https://groups-api.dataporten.no/groups/me/groups?show_all=true", {
headers: {
'Authorization': 'Bearer ' + accessToken,
}
}, (err, resp, body) => {
if (err) {
return callback(err);
}
if (resp.statusCode !== 200) {
return callback(new Error(body));
}
let bodyParsedGroups;
try {
bodyParsedGroups = JSON.parse(body);
} catch (jsonError) {
return callback(new Error(body));
}
const profile = {
user_id: bodyParsed.sub,
email: bodyParsed.email,
"email_verified": bodyParsed.email_verified,
"name": bodyParsed.name,
"feide-groups": bodyParsedGroups,
};
callback(null, profile);
});
}
);
}
}
Loading