a2d61a1daa
* twitch account linking; profile page twitch panel; twitch landing page * fix import * twitch logo * save twitch credentials cloud function * use user id instead of bot id, add manifold api endpoint * properly add function to index * Added support for new redirect Twitch auth. * Added clean error handling in case of Twitch link fail. * remove simulator * Removed legacy non-redirect Twitch auth code. Added "add bot to channel" button in user profile and relevant data to user type. * Removed unnecessary imports. * Fixed line endings. * Allow users to modify private user twitchInfo firestore object * Local dev on savetwitchcredentials function Co-authored-by: Phil <phil.bladen@gmail.com> Co-authored-by: Marshall Polaris <marshall@pol.rs>
23 lines
534 B
TypeScript
23 lines
534 B
TypeScript
import * as admin from 'firebase-admin'
|
|
import { z } from 'zod'
|
|
|
|
import { newEndpoint, validate } from './api'
|
|
|
|
const bodySchema = z.object({
|
|
twitchInfo: z.object({
|
|
twitchName: z.string(),
|
|
controlToken: z.string(),
|
|
}),
|
|
})
|
|
|
|
|
|
export const savetwitchcredentials = newEndpoint({}, async (req, auth) => {
|
|
const { twitchInfo } = validate(bodySchema, req.body)
|
|
const userId = auth.uid
|
|
|
|
await firestore.doc(`private-users/${userId}`).update({ twitchInfo })
|
|
return { success: true }
|
|
})
|
|
|
|
const firestore = admin.firestore()
|