Commit Graph

20 Commits

Author SHA1 Message Date
Asaf Gartner 1aab3b47b3 FreyaMode won't affect other message processing steps 2024-05-14 17:55:23 +03:00
Ben Visness 23b1b30d22 Less wrong Freya mode, I hope 2024-05-14 09:40:05 -05:00
Ben Visness ac54793fd0 Freya mode 2024-05-14 09:32:49 -05:00
Asaf Gartner 4568def378 Added a bunch of discord debugging 2024-03-28 21:24:46 +02:00
Asaf Gartner cd36eb44eb Don't require url/asset for snippet creation from discord. 2024-03-04 21:19:56 +02:00
Asaf Gartner 444f43a195 Added !til for discord messages 2024-03-04 21:09:40 +02:00
Ben Visness 76be9b668a Republish Discord announcements to Abner's Matrix server 2023-12-05 23:55:39 -06: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 efc7d76cb7 Snippet creation and editing 2022-08-06 00:41:37 +03:00
Asaf Gartner ac2d00aca7 Logging bad discord resources 2022-05-30 21:56:09 +03:00
Asaf Gartner 2bb14c1794 Replaced panic with error 2022-05-30 21:52:13 +03:00
Ben Visness 475716322f Fix up missing avatars 2022-05-21 16:44:39 -05:00
Ben Visness c1fa6cae13 Integrate Nick's local S3 server
Works like a charm!

Small tweak for clarity
2022-05-14 00:48:19 -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 43651d98e8 Code review 2022-02-07 14:21:40 +02:00
Asaf Gartner 92d6a31aa9 Fixed tag removal issue. 2022-01-31 10:22:25 +02:00
Asaf Gartner 378d6eb836 Removed old comment. 2022-01-31 08:52:56 +02:00
Asaf Gartner 60a71d5dd1 Fixed indent. 2022-01-31 08:51:34 +02:00
Asaf Gartner ad888346ef Discord message handling reorganization. 2022-01-31 08:46:43 +02:00