Commit Graph

30 Commits

Author SHA1 Message Date
Ben Visness 5427092708 Fix incorrect snippet queries (and generify some utilities) 2024-06-20 19:17:06 -05:00
Asaf Gartner d9073db5d0 Timeline/follow fetching done 2024-06-20 18:09:15 -05: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: hmn/hmn#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 d70f7d6b6d More twitch logs 2022-10-20 12:43:26 +03:00
Asaf Gartner 48451a49dd SQL fix 2022-10-20 12:43:26 +03:00
Asaf Gartner f548495813 Trying some debugging 2022-10-20 12:43:26 +03:00
Asaf Gartner 09d875a9f6 Trying another fix 2022-10-20 12:43:26 +03:00
Asaf Gartner 56929e6e44 Fixed twitch history query 2022-10-20 12:43:26 +03:00
Asaf Gartner cf809a3cdc Twitch fixes 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
Asaf Gartner 42e1ed95fb Added logs for twitch 2022-08-29 01:18:55 +03:00
Asaf Gartner b165bf7c23 Added panic recovery to all of our background jobs
Fixes issue #32
2022-06-16 00:33:57 +03:00
Asaf Gartner fe545ff0f3 Debugging twitch 2022-05-30 21:19:54 +03:00
Asaf Gartner 8c47590b99 Debugging twitch 2022-05-30 19:08:09 +03:00
Asaf Gartner 9fcc2321ca Hopefully fixed desync with twitch 2022-05-30 18:49:30 +03:00
Asaf Gartner 0d0773fd0e Reverse streamer sort and replaced green circle with red 2022-05-27 16:34:34 +03:00
Asaf Gartner 8495982d3f Added persistent vars and improved stream tracking on discord. 2022-05-27 11:37:43 +03: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 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 8951bf1aa5 Timers timers timers 2022-03-27 20:30:24 +03:00
Asaf Gartner 70cd2ec72b Added logs 2022-03-27 19:41:21 +03:00
Asaf Gartner febec72325 Only track approved users. 2022-03-27 19:13:47 +03:00
Asaf Gartner b0cf3e2f15 Probably fixed issue with twitch 2022-03-22 21:00:50 +02:00
Asaf Gartner 5ecd5a8a31 Debugging twitch in beta 2022-03-22 20:52:05 +02:00
Asaf Gartner c8096b0fb7 Loosened expected status codes from twitch 2022-03-22 20:34:42 +02:00
Asaf Gartner 11dd75ad03 Twitch monitoring 2022-03-22 20:07:43 +02:00