Skip to content

Commit

Permalink
Set up Discord OAuth2 (#16)
Browse files Browse the repository at this point in the history
* add oauth2 redirect

* wip

* wip

Reference:
- https://discord.com/developers/docs/topics/oauth2
- https://npmjs.com/package/@deno/kv
-

* added components for availability, data, datetime, time

* added sample data for the new question types

* Fixed Datetime question input

* wip

* Ran formating and added availability question

* Removed unnecessary AvailabilityQuestionValue from imports in form.svelte

* Fixed spelling error lol

* Added the name attribute to question types changed sumbit button

* blindly-coded wip

* wip

* wip

* wip

* add form and submission to `Store` interface

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Update kv.ts

* wip

* update tentative landing page

* wip getting sessions to seemingly work maybe

TODO: remove rogue console log statements.

* Delete +server.ts

* run `npm run lint`

* add form preview components

* wip

* wip

* Squashed commit of the following:

commit 71e0b11
Author: Alexander Peras <[email protected]>
Date:   Fri Feb 9 04:42:49 2024 -0800

    npm run format

commit 7b981e9
Author: Alexander Peras <[email protected]>
Date:   Fri Feb 9 04:36:09 2024 -0800

    fixed textarea resizing after changing fieldset

commit 3e947e7
Author: Alexander Peras <[email protected]>
Date:   Fri Feb 9 04:11:33 2024 -0800

    npm run format

commit 7798511
Author: Alexander Peras <[email protected]>
Date:   Fri Feb 9 04:07:59 2024 -0800

    added choiceIndex functionality

commit 05adf31
Author: Alexander Peras <[email protected]>
Date:   Fri Feb 9 03:47:08 2024 -0800

    added functionality for custom choice

commit 2150ac7
Author: Alexander Peras <[email protected]>
Date:   Fri Feb 9 03:31:02 2024 -0800

    npm run format and fixed lint errors

commit cdffee6
Author: Alexander Peras <[email protected]>
Date:   Fri Feb 9 03:18:23 2024 -0800

    replaced default with value in form.ts and all interfaces

commit 2106f9f
Author: AlexthePear <[email protected]>
Date:   Tue Feb 6 14:54:16 2024 -0800

    ran npm run format

commit 2b79740
Author: AlexthePear <[email protected]>
Date:   Tue Feb 6 14:51:15 2024 -0800

    FIXED: SingleTextSelectQuestion Value didn't extend QuestionValueBase

commit 5222508
Author: AlexthePear <[email protected]>
Date:   Sat Feb 3 17:38:01 2024 -0800

    wip

commit 03c0572
Author: AlexthePear <[email protected]>
Date:   Sat Feb 3 16:10:03 2024 -0800

    WIP: changing availiability question from using data.defualt to AvailabilityQuestionValue to store data

commit 964b6e3
Author: AlexthePear <[email protected]>
Date:   Sat Feb 3 15:41:26 2024 -0800

    reformated files

commit 04f1012
Merge: 63b8577 0bf9f59
Author: AlexthePear <[email protected]>
Date:   Sat Feb 3 15:40:16 2024 -0800

    Merge branch 'new-form-questions' of https://github.com/acmcsufoss/form into new-form-questions

commit 63b8577
Author: AlexthePear <[email protected]>
Date:   Sat Feb 3 15:39:57 2024 -0800

    wrapped all questions in fieldset and replaced label with <legend>

commit 0bf9f59
Author: Alexander Peras <[email protected]>
Date:   Wed Jan 31 13:40:35 2024 -0800

    fixed text area question resizing

commit 7538b33
Author: Alexander Peras <[email protected]>
Date:   Wed Jan 31 13:35:07 2024 -0800

    Added validation for avaliability question so its always a valid input

* wip

* fixed demo_form css

* fix demo form

* Update +page.svelte

* add form editor notes

* add check to createForm

* add redirect to `/discord_oauth2/logout` endpoint

* add `DENO_KV_CONNECT_URL` env var

* check workflow: copy default env vars

* check workflow: copy default env vars

* move db files to `.denokv` directory

* Update check.yaml

* check workflow: omit build step

* replace default `kvPath`

* edit form editor component

---------

Co-authored-by: Kaitlyn Jao <[email protected]>
Co-authored-by: AlexthePear <[email protected]>
Co-authored-by: AlexthePear <[email protected]>
  • Loading branch information
4 people authored Feb 23, 2024
1 parent 279511a commit c7943d3
Show file tree
Hide file tree
Showing 71 changed files with 4,365 additions and 495 deletions.
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
DENO_KV_ACCESS_TOKEN=""
DENO_KV_CONNECT_URL=""
DISCORD_REDIRECT_URI=""
DISCORD_CLIENT_ID=""
DISCORD_CLIENT_SECRET=""
DISCORD_GUILD_ID=""
DISCORD_ROLE_ID=""
DISCORD_BOT_TOKEN=""
9 changes: 6 additions & 3 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ jobs:
- name: Install Dependencies
run: npm ci

- name: Set up .env
run: cp .env.example .env

- name: Set up .env
run: cp .env.example .env

- name: Svelte check
run: npm run check

Expand All @@ -44,6 +50,3 @@ jobs:

- name: Lint
run: npm run lint && git diff --exit-code

- name: Build
run: npm run build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ node_modules
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
.denokv*
183 changes: 183 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,11 @@
"typescript": "^5.0.0",
"vite": "^4.4.2"
},
"type": "module"
"type": "module",
"dependencies": {
"@deno/kv": "^0.7.0",
"discord-api-types": "^0.37.67",
"export-to-csv": "^1.2.2",
"ulid": "^2.3.0"
}
}
7 changes: 6 additions & 1 deletion src/app.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import type { User } from '$lib/store';

// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface Platform {}

interface Locals {
user: User | undefined;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="%sveltekit.assets%/global.css" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
Expand Down
15 changes: 15 additions & 0 deletions src/hooks.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Handle } from '@sveltejs/kit';
import { s } from '$lib/resources/store';
import { SESSION_ID_COOKIE_NAME } from '$lib/oauth2';

export const handle: Handle = async ({ event, resolve }) => {
const sessionID = event.cookies.get(SESSION_ID_COOKIE_NAME);
if (sessionID) {
const user = await s.getUserBySessionID(sessionID);
if (user) {
event.locals.user = user;
}
}

return await resolve(event);
};
Loading

0 comments on commit c7943d3

Please sign in to comment.