Skip to content

Commit

Permalink
fix: matrix registration bug
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbrusegard committed Jan 20, 2025
1 parent 06ad9ca commit 5513570
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
20 changes: 3 additions & 17 deletions src/components/auth/AccountSignUpForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
FormMessage,
useForm,
} from '@/components/ui/Form';
import type { TRPCClientError } from '@/lib/api/types';

function AccountSignUpForm() {
const router = useRouter();
Expand All @@ -27,29 +26,16 @@ function AccountSignUpForm() {
const signUpMutation = api.auth.signUp.useMutation({
onMutate: () => setPending(true),
onSettled: () => setPending(false),
onSuccess: () => router.push('/auth/success'),
});

const form = useForm(formSchema, {
validators: {
onChange: formSchema,
onSubmitAsync: async ({ value }) => {
try {
await signUpMutation.mutateAsync(value);
} catch (error: unknown) {
const TRPCError = error as TRPCClientError;
if (!TRPCError.data?.toast) {
return { fields: { password: TRPCError.message } };
}
return ' ';
}
},
},
defaultValues: {
password: '',
confirmPassword: '',
},
onSubmit: () => {
router.push('/auth/success');
onSubmit: ({ value }) => {
signUpMutation.mutate(value);
},
});

Expand Down
1 change: 1 addition & 0 deletions src/server/api/routers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ const authRouter = createRouter({
throw new TRPCError({
code: 'BAD_REQUEST',
message: ctx.t('auth.form.password.weak'),
cause: { toast: 'error' },
});
}

Expand Down

0 comments on commit 5513570

Please sign in to comment.