-
Notifications
You must be signed in to change notification settings - Fork 2
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
Membership #1153
Draft
jotjern
wants to merge
17
commits into
main
Choose a base branch
from
membership
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Membership #1153
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
37d0bc8
Add membership to user
jotjern 2c06105
Move membership schema to own file
jotjern 92dfbd7
Implement feide groups repository
jotjern c87edce
Implement NTNU studyplan api repository
jotjern 1fb6cea
Remove test code from repository
jotjern 162a3fa
Add warning to ntnu studyplan repository
jotjern 19a7088
Add static fallback for studyplan repository
jotjern e3bfa19
Remove test code and only expose needed methods in studyplan repository
jotjern e96643a
Add MIT fallback data
jotjern 0c5bbac
Implement year calculation and some other stuff
jotjern 59e3c84
Remove dead code
jotjern 143151a
Lint
jotjern e1d1937
Merge branch 'main' into membership
jotjern 15d87cd
Add grade calculation and other stuff
jotjern aeb6088
Fix type problem
jotjern 0c64135
Remove console log
jotjern 99956cc
Merge branch 'main' into membership
jotjern File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 25 additions & 7 deletions
32
apps/web/src/components/molecules/ProfileMolecules/StudyProgressionBox.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Handler that will be called during the execution of a PostLogin flow. | ||
* | ||
* @param {Event} event - Details about the user and the context in which they are logging in. | ||
* @param {PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login. | ||
*/ | ||
exports.onExecutePostLogin = async (event, api) => { | ||
// Only try to link accounts when logging in via Feide | ||
if (event.connection.id !== event.secrets.FEIDE_CONNECTION_ID) { | ||
return; | ||
} | ||
|
||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,11 @@ | |
"name": "monorepo", | ||
"version": "1.0.0", | ||
"description": "Monoweb is the next-generation web application for Online. This is the monorepo source.", | ||
"keywords": ["online", "ntnu", "student-association"], | ||
"keywords": [ | ||
"online", | ||
"ntnu", | ||
"student-association" | ||
], | ||
"homepage": "https://online.ntnu.no", | ||
"author": "Dotkom <[email protected]> (https://online.ntnu.no)", | ||
"bugs": { | ||
|
@@ -24,24 +28,27 @@ | |
"lint-check": "turbo run lint-check", | ||
"test": "turbo run test", | ||
"test:it": "turbo run test:it", | ||
"dev": "pnpm -rc -F @dotkomonline/web -F @dotkomonline/dashboard -F @dotkomonline/rpc -F @dotkomonline/invoicification -F @dotkomonline/rif exec doppler run --preserve-env pnpm run dev", | ||
"migrate": "pnpm -rc -F @dotkomonline/migrator exec doppler run --preserve-env pnpm run migrate", | ||
"migrate-down": "pnpm -rc -F @dotkomonline/migrator exec doppler run --preserve-env pnpm run migrate -- down", | ||
"migrate-down-all": "pnpm -rc -F @dotkomonline/migrator exec doppler run --preserve-env pnpm run migrate", | ||
"migrate-with-fixtures": "pnpm -rc -F @dotkomonline/migrator exec doppler run --preserve-env pnpm run migrate latest --with-fixtures", | ||
"migrate-with-sample-data": "pnpm -rc -F @dotkomonline/migrator exec doppler run --preserve-env pnpm run migrate -- latest --sample-data", | ||
"dev": "pnpm -rc -F @dotkomonline/web -F @dotkomonline/dashboard -F @dotkomonline/rpc -F @dotkomonline/invoicification -F @dotkomonline/rif exec doppler run --preserve-env -- pnpm run dev", | ||
"migrate": "pnpm -rc -F @dotkomonline/migrator exec doppler run -- pnpm run migrate", | ||
"migrate-down": "pnpm -rc -F @dotkomonline/migrator exec doppler run -- pnpm run migrate -- down", | ||
"migrate-down-all": "pnpm -rc -F @dotkomonline/migrator exec doppler run -- pnpm run migrate", | ||
"migrate-with-fixtures": "pnpm -rc -F @dotkomonline/migrator exec doppler run -- pnpm run migrate latest --with-fixtures", | ||
"migrate-with-sample-data": "pnpm -rc -F @dotkomonline/migrator exec doppler run -- pnpm run migrate -- latest --sample-data", | ||
Comment on lines
-27
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs rebase |
||
"storybook": "turbo run storybook --filter=storybook", | ||
"type-check": "turbo run type-check", | ||
"clean": "turbo run clean", | ||
"docker:login": "aws ecr get-login-password --region eu-north-1 | docker login --username AWS --password-stdin 891459268445.dkr.ecr.eu-north-1.amazonaws.com", | ||
"docker:login:public": "aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws", | ||
"shell": "pnpm --filter=@dotkomonline/shell start" | ||
}, | ||
"workspaces": ["packages/*", "apps/*"], | ||
"packageManager": "[email protected]", | ||
"workspaces": [ | ||
"packages/*", | ||
"apps/*" | ||
], | ||
"packageManager": "[email protected]", | ||
"engines": { | ||
"node": ">=20.12.2", | ||
"pnpm": ">=9.15.5" | ||
"pnpm": ">=9.0.0" | ||
}, | ||
"devDependencies": { | ||
"turbo": "^2.3.4", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
packages/core/src/modules/external/feide-groups-repository.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { z } from "zod" | ||
|
||
type GroupType = "subject" | "studyProgramme" | "studySpecialisation" | ||
|
||
export type FeideGroup = { | ||
name: string | ||
code: string | ||
finished?: Date | ||
} | ||
|
||
export type StudentInformation = { | ||
courses: FeideGroup[] | ||
studyProgrammes: FeideGroup[] | ||
studySpecializations: FeideGroup[] | ||
} | ||
|
||
export interface FeideGroupsRepository { | ||
getStudentInformation(accessToken: string): Promise<StudentInformation> | ||
} | ||
|
||
const FeideResponseGroupSchema = z.object({ | ||
id: z.string(), | ||
type: z.string(), | ||
displayName: z.string(), | ||
parent: z.string().optional(), | ||
membership: z | ||
.object({ | ||
basic: z.string(), | ||
displayName: z.string().optional(), | ||
notAfter: z.string().optional(), | ||
notBefore: z.string().optional(), | ||
}) | ||
.optional(), | ||
}) | ||
|
||
export class FeideGroupsRepositoryImpl implements FeideGroupsRepository { | ||
private readonly baseUrl = "https://groups-api.dataporten.no/groups" | ||
|
||
private responseGroupToFeideGroup(group: z.infer<typeof FeideResponseGroupSchema>): FeideGroup { | ||
return { | ||
name: group.displayName, | ||
code: group.id.split(":")[5], | ||
finished: group.membership?.notAfter ? new Date(group.membership.notAfter) : undefined, | ||
} | ||
} | ||
|
||
async getStudentInformation(accessToken: string): Promise<StudentInformation> { | ||
const response = await fetch(`${this.baseUrl}/me/groups`, { | ||
headers: { | ||
Authorization: `Bearer ${accessToken}`, | ||
}, | ||
}) | ||
|
||
if (!response.ok) { | ||
throw new Error(`Failed to fetch student information: ${await response.text()}`) | ||
} | ||
|
||
const responseGroups = z.array(FeideResponseGroupSchema).parse(await response.json()) | ||
|
||
const courses = responseGroups.filter((group) => group.type === "fc:fs:emne").map(this.responseGroupToFeideGroup) | ||
|
||
const studySpecializations = responseGroups | ||
.filter((group) => group.type === "fc:fs:str") | ||
.map(this.responseGroupToFeideGroup) | ||
|
||
const studyProgrammes = responseGroups | ||
.filter((group) => group.type === "fc:fs:prg") | ||
.map(this.responseGroupToFeideGroup) | ||
|
||
return { | ||
courses, | ||
studyProgrammes, | ||
studySpecializations, | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra newlines