Skip to content

Commit

Permalink
chore: disable getUserProfile
Browse files Browse the repository at this point in the history
  • Loading branch information
gaboesquivel committed Apr 8, 2024
1 parent ea35c4e commit e15ef3e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
11 changes: 10 additions & 1 deletion apps/masterbots.ai/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,18 @@ import { Providers } from '@/components/layout/providers'
import { cn } from '@/lib/utils'
import { GlobalStoreProvider } from '@/hooks/use-global-store'

export default async function RootLayout({ children }: RootLayoutProps) {
async function getCookieData(): Promise<{ hasuraJwt; userProfile }> {
const hasuraJwt = cookies().get('hasuraJwt')?.value || ''
const userProfile = cookies().get('userProfile')?.value || null
return new Promise(resolve =>
setTimeout(() => {
resolve({ hasuraJwt, userProfile })
}, 1000)
)
}

export default async function RootLayout({ children }: RootLayoutProps) {
const { hasuraJwt, userProfile } = await getCookieData()

return (
<html lang="en" suppressHydrationWarning>
Expand Down
37 changes: 19 additions & 18 deletions apps/masterbots.ai/services/supabase/supa-server.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,27 @@ import { createSupabaseServerClient } from './supa-server-client'

export async function getUserProfile(): Promise<UserProfile | null> {
try {
const supabase = await createSupabaseServerClient()
const {
data: { user }
} = await supabase.auth.getUser()
if (!user || !user.email) throw new Error('user not found')
return null
// const supabase = await createSupabaseServerClient()
// const {
// data: { user }
// } = await supabase.auth.getUser()
// if (!user || !user.email) throw new Error('user not found')

// TODO: use supabase
const userProfile = await getUser({
email: user.email,
adminSecret: process.env.HASURA_GRAPHQL_ADMIN_SECRET || ''
})
// // TODO: use supabase
// const userProfile = await getUser({
// email: user.email,
// adminSecret: process.env.HASURA_GRAPHQL_ADMIN_SECRET || ''
// })

if (!userProfile) throw new Error('user not found')
return {
userId: userProfile.userId,
username: userProfile.username,
name: '',
email: userProfile.email,
image: userProfile.profilePicture || ''
}
// if (!userProfile) throw new Error('user not found')
// return {
// userId: userProfile.userId,
// username: userProfile.username,
// name: '',
// email: userProfile.email,
// image: userProfile.profilePicture || ''
// }
} catch (error) {
console.log('GET USER PROFILE ERROR', error)
return null
Expand Down

0 comments on commit e15ef3e

Please sign in to comment.