fix: auth
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { useTRPC } from '@/integrations/trpc/react';
|
import { useTRPC } from '@/integrations/trpc/react';
|
||||||
import { zodResolver } from '@hookform/resolvers/zod';
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
import { zSignUpEmail } from '@openpanel/validation';
|
import { zSignUpEmail } from '@openpanel/validation';
|
||||||
import { useMutation } from '@tanstack/react-query';
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { useRouter } from '@tanstack/react-router';
|
import { useRouter } from '@tanstack/react-router';
|
||||||
import { type SubmitHandler, useForm } from 'react-hook-form';
|
import { type SubmitHandler, useForm } from 'react-hook-form';
|
||||||
@@ -16,11 +16,10 @@ type IForm = z.infer<typeof validator>;
|
|||||||
export function SignUpEmailForm({
|
export function SignUpEmailForm({
|
||||||
inviteId,
|
inviteId,
|
||||||
}: { inviteId: string | undefined }) {
|
}: { inviteId: string | undefined }) {
|
||||||
const router = useRouter();
|
|
||||||
const trpc = useTRPC();
|
const trpc = useTRPC();
|
||||||
const mutation = useMutation(
|
const mutation = useMutation(
|
||||||
trpc.auth.signUpEmail.mutationOptions({
|
trpc.auth.signUpEmail.mutationOptions({
|
||||||
onSuccess() {
|
async onSuccess() {
|
||||||
toast.success('Successfully signed up');
|
toast.success('Successfully signed up');
|
||||||
window.location.href = '/onboarding/project';
|
window.location.href = '/onboarding/project';
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -9,16 +9,12 @@ import { createIsomorphicFn } from '@tanstack/react-start';
|
|||||||
import { getRequestHeaders } from '@tanstack/react-start/server';
|
import { getRequestHeaders } from '@tanstack/react-start/server';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
|
|
||||||
type Headers = ReturnType<typeof getRequestHeaders>;
|
|
||||||
|
|
||||||
export const getIsomorphicHeaders = createIsomorphicFn()
|
export const getIsomorphicHeaders = createIsomorphicFn()
|
||||||
.server(() => {
|
.server(() => {
|
||||||
return getRequestHeaders();
|
return getRequestHeaders();
|
||||||
})
|
})
|
||||||
.client(() => {
|
.client(() => {
|
||||||
const headers = new Headers();
|
return {};
|
||||||
headers.set('content-type', 'application/json');
|
|
||||||
return headers as Headers;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create a function that returns a tRPC client with optional cookies
|
// Create a function that returns a tRPC client with optional cookies
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ export async function validateSessionToken(
|
|||||||
return EMPTY_SESSION;
|
return EMPTY_SESSION;
|
||||||
}
|
}
|
||||||
const sessionId = encodeHexLowerCase(sha256(new TextEncoder().encode(token)));
|
const sessionId = encodeHexLowerCase(sha256(new TextEncoder().encode(token)));
|
||||||
const result = await db.session.findUnique({
|
const result = await db.$primary().session.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id: sessionId,
|
id: sessionId,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -321,7 +321,6 @@ export const authRouter = createTRPCRouter({
|
|||||||
return true;
|
return true;
|
||||||
}),
|
}),
|
||||||
session: publicProcedure.query(async ({ ctx }) => {
|
session: publicProcedure.query(async ({ ctx }) => {
|
||||||
ctx.req.log.info('DEBUG: session', { session: ctx.session });
|
|
||||||
return ctx.session;
|
return ctx.session;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user