Added support for new redirect Twitch auth.

This commit is contained in:
Phil 2022-09-03 17:08:05 +01:00
parent f3f71af830
commit 6eb4286053

View File

@ -2,7 +2,7 @@ import { User, PrivateUser } from 'common/user'
import { generateNewApiKey } from '../api/api-key' import { generateNewApiKey } from '../api/api-key'
import { updatePrivateUser } from '../firebase/users' import { updatePrivateUser } from '../firebase/users'
const TWITCH_BOT_PUBLIC_URL = 'https://king-prawn-app-5btyw.ondigitalocean.app' const TWITCH_BOT_PUBLIC_URL = 'https://king-prawn-app-5btyw.ondigitalocean.app' // TODO: Add this to env config appropriately
export async function initLinkTwitchAccount( export async function initLinkTwitchAccount(
manifoldUserID: string, manifoldUserID: string,
@ -16,6 +16,7 @@ export async function initLinkTwitchAccount(
body: JSON.stringify({ body: JSON.stringify({
manifoldID: manifoldUserID, manifoldID: manifoldUserID,
apiKey: manifoldUserAPIKey, apiKey: manifoldUserAPIKey,
redirectURL: window.location.href,
}), }),
}) })
const responseData = await response.json() const responseData = await response.json()
@ -38,7 +39,7 @@ export async function linkTwitchAccount(user: User, privateUser: PrivateUser) {
) )
console.log('opening twitch link', twitchAuthURL) console.log('opening twitch link', twitchAuthURL)
window.open(twitchAuthURL) window.location.href = twitchAuthURL
const twitchInfo = await linkSuccessPromise const twitchInfo = await linkSuccessPromise
await updatePrivateUser(user.id, { twitchInfo }) await updatePrivateUser(user.id, { twitchInfo })