aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/components
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2026-02-01 17:20:17 +0000
committerGitHub <noreply@github.com>2026-02-01 17:20:17 +0000
commit4051594b2f410f01e883febad22eb9001a84f90e (patch)
tree37b74d93192e2399fb50a31436150ba671b2b5cc /apps/web/components
parent67501ed6229a63efc29b34513fac35239bd4f8e4 (diff)
downloadkarakeep-4051594b2f410f01e883febad22eb9001a84f90e.tar.zst
feat: add support for redirectUrl after signup (#2439)
* feat: add support for redirectUrl after signup * pr review * more fixes * format * another fix
Diffstat (limited to 'apps/web/components')
-rw-r--r--apps/web/components/signup/SignUpForm.tsx20
1 files changed, 16 insertions, 4 deletions
diff --git a/apps/web/components/signup/SignUpForm.tsx b/apps/web/components/signup/SignUpForm.tsx
index f758bfda..15b64fab 100644
--- a/apps/web/components/signup/SignUpForm.tsx
+++ b/apps/web/components/signup/SignUpForm.tsx
@@ -35,10 +35,15 @@ import { z } from "zod";
import { useTRPC } from "@karakeep/shared-react/trpc";
import { zSignUpSchema } from "@karakeep/shared/types/users";
+import { isMobileAppRedirect } from "@karakeep/shared/utils/redirectUrl";
const VERIFY_EMAIL_ERROR = "Please verify your email address before signing in";
-export default function SignUpForm() {
+interface SignUpFormProps {
+ redirectUrl: string;
+}
+
+export default function SignUpForm({ redirectUrl }: SignUpFormProps) {
const api = useTRPC();
const form = useForm<z.infer<typeof zSignUpSchema>>({
resolver: zodResolver(zSignUpSchema),
@@ -113,7 +118,10 @@ export default function SignUpForm() {
}
form.clearErrors("turnstileToken");
try {
- await createUserMutation.mutateAsync(value);
+ await createUserMutation.mutateAsync({
+ ...value,
+ redirectUrl,
+ });
} catch (e) {
if (e instanceof TRPCClientError) {
setErrorMessage(e.message);
@@ -133,7 +141,7 @@ export default function SignUpForm() {
if (!resp || !resp.ok || resp.error) {
if (resp?.error === VERIFY_EMAIL_ERROR) {
router.replace(
- `/check-email?email=${encodeURIComponent(value.email.trim())}`,
+ `/check-email?email=${encodeURIComponent(value.email.trim())}&redirectUrl=${encodeURIComponent(redirectUrl)}`,
);
} else {
setErrorMessage(
@@ -147,7 +155,11 @@ export default function SignUpForm() {
}
return;
}
- router.replace("/");
+ if (isMobileAppRedirect(redirectUrl)) {
+ window.location.href = redirectUrl;
+ } else {
+ router.replace(redirectUrl);
+ }
})}
className="space-y-4"
>