Skip to content

Commit

Permalink
fix: chat auth bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gaboesquivel committed Apr 8, 2024
1 parent ffe0280 commit f127889
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/masterbots.ai/app/c/[chatbot]/[threadId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default async function ChatPage({ params }: ChatPageProps) {
const {
data: { user }
} = await supabase.auth.getUser()
if (!user || !user.email) throw new Error('user not found')
if (!user || !user.email) redirect(`/auth/sign-in`)

const jwt = cookies().get('hasuraJwt')?.value || ''

Expand Down
4 changes: 2 additions & 2 deletions apps/masterbots.ai/app/c/[chatbot]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ export default async function BotThreadsPage({
const {
data: { user }
} = await supabase.auth.getUser()
if (!user || !user.email) throw new Error('user not found')
if (!user || !user.email) redirect(`/auth/sign-in`)
const userProfile = await getUser({
email: user.email,
adminSecret: process.env.HASURA_GRAPHQL_ADMIN_SECRET || ''
})

if (!userProfile) throw new Error('user not found')
if (!userProfile) redirect(`/auth/sign-in`)
const jwt = cookies().get('hasuraJwt')?.value || ''

// NOTE: maybe we should use same expiration time
Expand Down
5 changes: 3 additions & 2 deletions apps/masterbots.ai/app/c/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ export default async function IndexPage() {
const {
data: { user }
} = await supabase.auth.getUser()
if (!user || !user.email) throw new Error('user not found')
if (!user || !user.email) redirect(`/auth/sign-in`)

const dbUserProfile = await getUser({
email: user.email,
adminSecret: process.env.HASURA_GRAPHQL_ADMIN_SECRET || ''
})

if (!dbUserProfile) throw new Error('user not found')
if (!dbUserProfile) redirect(`/auth/sign-in`)

const jwt = cookies().get('hasuraJwt').value || ''

Expand Down

0 comments on commit f127889

Please sign in to comment.