-
Notifications
You must be signed in to change notification settings - Fork 4
Added whitelist for event #609
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9bb6690
feat: added whitelist so that only specific people can join event
PaulicStudios b64d94c
fix: tilt api env var for OAUTH_42_SUCCESS_REDIRECT_URL
PaulicStudios 0e47e21
Replace event whitelist migration and update related services
PaulicStudios 459d7f3
fix: apply CodeRabbit auto-fixes
coderabbitai[bot] 0f0acdb
fix: revert change of env var
PaulicStudios e5ef557
chore: pnpm lint
PaulicStudios 922f9b5
fix: when there are no whitelist entries anyone can join a private event
PaulicStudios 00b316b
Extract WhitelistPlatform enum and deduplicate key logic
PaulicStudios 92ad035
fix: compile error
PaulicStudios bb84765
Trim whitelist usernames before matching
PaulicStudios 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 hidden or 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,16 @@ | ||
| import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
|
||
| export class EventWhitelist1775336799887 implements MigrationInterface { | ||
| name = 'EventWhitelist1775336799887' | ||
|
|
||
| public async up(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query(`CREATE TABLE "event_whitelists" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "platform" text NOT NULL, "username" character varying NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "eventId" uuid NOT NULL, CONSTRAINT "UQ_1e66e3e9750244ea3f6563a6d49" UNIQUE ("eventId", "username", "platform"), CONSTRAINT "PK_64d752c5410ff967a715cca3998" PRIMARY KEY ("id"))`); | ||
| await queryRunner.query(`ALTER TABLE "event_whitelists" ADD CONSTRAINT "FK_17ccbcee3723a35d6d691532c22" FOREIGN KEY ("eventId") REFERENCES "events"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); | ||
| } | ||
|
|
||
| public async down(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query(`ALTER TABLE "event_whitelists" DROP CONSTRAINT "FK_17ccbcee3723a35d6d691532c22"`); | ||
| await queryRunner.query(`DROP TABLE "event_whitelists"`); | ||
| } | ||
|
|
||
| } |
This file contains hidden or 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 hidden or 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,26 @@ | ||
| import { ArrayNotEmpty, IsArray, IsEnum, IsString, IsUUID, ValidateNested } from "class-validator"; | ||
| import { Type } from "class-transformer"; | ||
| import { WhitelistPlatform } from "../entities/event-whitelist.entity"; | ||
|
|
||
| export class WhitelistEntryDto { | ||
| @IsString() | ||
| username: string; | ||
|
|
||
| @IsEnum(WhitelistPlatform) | ||
| platform: WhitelistPlatform; | ||
| } | ||
|
|
||
| export class AddToWhitelistDto { | ||
| @IsArray() | ||
| @ArrayNotEmpty() | ||
| @ValidateNested({ each: true }) | ||
| @Type(() => WhitelistEntryDto) | ||
| entries: WhitelistEntryDto[]; | ||
| } | ||
|
|
||
| export class BulkDeleteWhitelistDto { | ||
| @IsArray() | ||
| @ArrayNotEmpty() | ||
| @IsUUID("4", { each: true }) | ||
| ids: string[]; | ||
| } |
This file contains hidden or 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,36 @@ | ||
| import { | ||
| Entity, | ||
| Column, | ||
| PrimaryGeneratedColumn, | ||
| CreateDateColumn, | ||
| ManyToOne, | ||
| Unique, | ||
| } from "typeorm"; | ||
| import { EventEntity } from "./event.entity"; | ||
|
|
||
| export enum WhitelistPlatform { | ||
| GITHUB = "GITHUB", | ||
| FORTYTWO = "FORTYTWO", | ||
| } | ||
|
|
||
| @Entity("event_whitelists") | ||
| @Unique(["event", "username", "platform"]) | ||
| export class EventWhitelistEntity { | ||
| @PrimaryGeneratedColumn("uuid") | ||
| id: string; | ||
|
|
||
| @Column({ type: "text" }) | ||
| platform: WhitelistPlatform; | ||
|
|
||
| @Column() | ||
| username: string; | ||
|
|
||
| @ManyToOne(() => EventEntity, { | ||
| onDelete: "CASCADE", | ||
| nullable: false, | ||
| }) | ||
| event: EventEntity; | ||
|
|
||
| @CreateDateColumn() | ||
| createdAt: Date; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.