Commit Graph

86 Commits

Author SHA1 Message Date
Asaf Gartner 4568def378 Added a bunch of discord debugging 2024-03-28 21:24:46 +02:00
Asaf Gartner 65aab39432 Asset thumbnail backend 2023-05-17 22:34:55 +03:00
bvisness 0210a0784b Add Discord login (#106)
This leverages our existing Discord OAuth implementation. Any users with a linked Discord account will be able to log in immediately. When logging in, we request the `email` scope in addition to `identity`, so existing users will be prompted one time to accept the new permissions. On subsequent logins, Discord will skip the prompt.

When linking your Discord account to an existing HMN account, we continue to only request the `identity` scope, so we do not receive the user's Discord email.

Both login and linking go through the same Discord OAuth callback. All flows through the callback try to achieve the same end goal: a logged-in HMN user with a linked Discord account.

Linking works the same as it ever has. Login, however, is different because we do not have a session ID to use as the OAuth state. To account for this, I have added a `pending_login` table that stores a secure unique ID and the eventual destination URL. These pending logins expire after 10 minutes. When we receive the OAuth callback, we look up the pending login by the OAuth `state` and immediately delete it. The destination URL will be used to redirect the user to the right place.

If we have a `discord_user` entry for the OAuth'd Discord user, we immediately log the user into the associated HMN account. This is the typical login case. If we do not have a `discord_user`, but there is exactly one HMN user with the same email address as the Discord user, we will link the two accounts and log into the HMN account.

(It is possible for multiple HMN accounts to have the same email, because we don't have a uniqueness constraint there. We fail the login in this case rather than link to the wrong account.)

Finally, if no associated HMN user exists, a new one will be created. It will use the Discord user's username, email, and avatar. This user will have no password, but they can set or reset a password through the usual flows.

Co-authored-by: Ben Visness <bvisness@gmail.com>
Reviewed-on: #106
2023-05-06 19:38:50 +00:00
Asaf Gartner aa6428f3a4 Removed remaining pgxv4 stuff and fixed twitch tags 2023-01-29 08:53:57 +02:00
Asaf Gartner 2af28d9f3f Update pgx v4 to pgx v5 2023-01-29 08:53:57 +02:00
Asaf Gartner a6ad01143a Twitch should work now hopefully. 2022-10-20 12:43:26 +03:00
Asaf Gartner 0f58cfc2da Added support for db arrays and some twitch fixes. 2022-10-20 12:43:26 +03:00
Asaf Gartner 5cc920dc2f Better twitch tracking 2022-10-20 12:43:26 +03:00
bvisness d2b34cb87d Initial version of education content (#90)
Co-authored-by: Ben Visness <bvisness@gmail.com>
Reviewed-on: #90
2022-09-10 16:29:57 +00:00
Asaf Gartner 42e1ed95fb Added logs for twitch 2022-08-29 01:18:55 +03:00
Asaf Gartner efc7d76cb7 Snippet creation and editing 2022-08-06 00:41:37 +03:00
Ben Visness 62972ae35a Merge remote-tracking branch 'origin/master' into jam-2022 2022-08-04 18:37:51 -05:00
Ben Visness d164a58ba0 Fix issues with asset upload
It didn't work when creating a new project or editing personal projects,
due to routing issues. I also took this opportunity to make the script
support multiple form submit buttons, since in some cases we will have a
submit button on each tab, and I figured they all should respect the
fact that you have an upload in progress.
2022-08-01 21:59:42 -05:00
Asaf Gartner 9d1d249ec0 Added jam/project association. 2022-06-20 01:26:33 +03:00
Asaf Gartner 8495982d3f Added persistent vars and improved stream tracking on discord. 2022-05-27 11:37:43 +03:00
Ben Visness 491ae57590 Tweak Postgres help message on failed seed 2022-05-14 23:06:48 -05:00
Ben Visness 3aa16c6d12 Add owners to seeded projects 2022-05-11 23:39:43 -05:00
Ben Visness a2ec57cf47 Seed projects 2022-05-11 22:24:05 -05:00
Ben Visness e4bb741a15 Automatically create the HMN user if necessary
This pretty much certainly won't work in real environments. If it does,
your db config is not secure :)
2022-05-11 19:50:51 -05:00
Ben Visness f4601198c9 Seed news posts 2022-05-07 14:45:21 -05:00
Ben Visness 3c4238994a Seed example forum threads 2022-05-07 14:31:37 -05:00
Ben Visness 3a93aa93e9 Seed users (and rework a lot of user access to use new helpers) 2022-05-07 13:58:00 -05:00
Ben Visness b46f5d8637 Add bare minimum seed 2022-05-07 11:37:15 -05:00
Ben Visness 1020039ea2 Fix up tests 2022-05-07 09:43:41 -05:00
Ben Visness 0e56f56372 Rename all the db tables 2022-05-07 08:11:05 -05:00
Ben Visness a147cfa325 Rework DB API
This takes advantage of generics, and generally clears up a lot of
inconsistencies and quality-of-life issues.

Start of db rework: clean up, start generics, improve tests

Write some nice aspirational package docs

Rework and document the db API

Tests still pass, at least...now for everything else

Update all callsites of db functions

Finish converting all callsites

Not too bad actually! Centralizing access into the helpers makes a big
difference.

wtf it works
2022-05-06 16:56:13 -05:00
Asaf Gartner 11dd75ad03 Twitch monitoring 2022-03-22 20:07:43 +02:00
Asaf Gartner 8e7c20fffa Removed old project logo url fields 2022-02-13 22:07:09 +02:00
Asaf Gartner d32cd0a849 Removed old user avatar url field from the db 2022-02-13 21:52:29 +02:00
Asaf Gartner f4f439489d Assets for user avatars 2021-12-29 16:38:23 +02:00
Asaf Gartner 950e84d53a Personal project creation 2021-12-02 12:53:36 +02:00
Ben Visness 0cc879df21 Add tags to snippets on timelines 2021-11-11 11:00:46 -08:00
Ben Visness 5256e5c37c Add new tags data model 2021-11-10 10:19:22 -08:00
Ben Visness 5f7dedce93 Implement the down migration for personal projects 2021-11-10 09:53:24 -08:00
Ben Visness a4ad2c5f04 Update data model for personal projects
Also:
- Added a helper for fetching posts with appropriate visibility
- Added personal projects to the project index
2021-11-06 15:25:31 -05:00
Ben Visness 251446d6e4 Do jam showcase stuff 2021-09-24 22:53:00 -05:00
Ben Visness 9c7acd7dbb Add a sort field to subforums 2021-09-23 01:18:45 -05:00
Ben Visness 986a42c1ac Switch to centralized helpers for fetching threads/posts
This includes the ability to "shadowban" new users who have not yet been
approved. We do not have UI for approving these users.

Migrate deserving users to new Approved status

Add post fetching helpers as well

The logic in the thread/post stuff is definitely getting redundant, but
I'm not sure I'm yet ready to try to abstract any of it away.

The next thing to do is probably to update blogs and other places that
fetch threads/posts, and delete the old helpers.

Move forums and blogs fully to new helpers

Use the helpers on the landing page too

that was easy!

Fix up some spots I missed

Check user status and use helpers on the profile page
2021-09-22 23:48:31 -05:00
Asaf Gartner 7063fd5604 Added basic usage tracking for posts. 2021-09-22 22:18:39 +03:00
Ben Visness b2a35c469a Update project last updated fields on new forum/blog posts 2021-09-08 22:44:46 -05:00
Ben Visness 36bb2ce2d5 Put timestamp in avatar filenames to avoid cache problems 2021-09-07 19:55:52 -05:00
Ben Visness f1e2e99663 Don't treat replies to the OP as replies 2021-09-06 16:40:00 -05:00
Ben Visness b53770932d No longer require a migration in seedfile
We don't need to do this any more, since our database backups now
include the migration table. The seedfile command also no longer
requires the user to type a password.

This also prevents the Discord history bot from running when it has no
credentials.
2021-09-05 19:43:49 -05:00
Ben Visness 59f5243839 Prefix things with "public." inside Postgres functions
Boy is this a stupid behavior of Postgres, and one that only really
manifests when restoring data from a backup.
2021-09-05 17:43:34 -05:00
Ben Visness a42973c3cb More server setup stuff I dunno I'm sorry 2021-09-04 16:09:01 -05:00
Asaf Gartner 307a122518 Another attempt at crash mailing 2021-09-04 21:59:03 +03:00
Ben Visness c59b58daf0 Restrict project header links 2021-08-28 08:11:01 -05:00
Ben Visness a655fe96bc Fix up remaining project colors 2021-08-28 07:14:49 -05:00
Ben Visness 67b86720a9 Add user edit form
Add most of the user settings backend

still need to do discord lol

Add the Discord settings

Add avatar uploads
2021-08-27 17:18:02 -05:00
Ben Visness 719c0d230c Delete stuff on message delete
still need to do bulk delete
2021-08-26 18:33:39 -05:00