92
apps/console/src/__generated__/iam/VerifyEmailPageMutation.graphql.ts
generated
Normal file
92
apps/console/src/__generated__/iam/VerifyEmailPageMutation.graphql.ts
generated
Normal file
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* @generated SignedSource<<793a4f7b17b13f925362dab5dfb590e2>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import { ConcreteRequest } from 'relay-runtime';
|
||||
export type VerifyEmailInput = {
|
||||
token: string;
|
||||
};
|
||||
export type VerifyEmailPageMutation$variables = {
|
||||
input: VerifyEmailInput;
|
||||
};
|
||||
export type VerifyEmailPageMutation$data = {
|
||||
readonly verifyEmail: {
|
||||
readonly success: boolean;
|
||||
} | null | undefined;
|
||||
};
|
||||
export type VerifyEmailPageMutation = {
|
||||
response: VerifyEmailPageMutation$data;
|
||||
variables: VerifyEmailPageMutation$variables;
|
||||
};
|
||||
|
||||
const node: ConcreteRequest = (function(){
|
||||
var v0 = [
|
||||
{
|
||||
"defaultValue": null,
|
||||
"kind": "LocalArgument",
|
||||
"name": "input"
|
||||
}
|
||||
],
|
||||
v1 = [
|
||||
{
|
||||
"alias": null,
|
||||
"args": [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "input",
|
||||
"variableName": "input"
|
||||
}
|
||||
],
|
||||
"concreteType": "VerifyEmailPayload",
|
||||
"kind": "LinkedField",
|
||||
"name": "verifyEmail",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "success",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
];
|
||||
return {
|
||||
"fragment": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Fragment",
|
||||
"metadata": null,
|
||||
"name": "VerifyEmailPageMutation",
|
||||
"selections": (v1/*: any*/),
|
||||
"type": "Mutation",
|
||||
"abstractKey": null
|
||||
},
|
||||
"kind": "Request",
|
||||
"operation": {
|
||||
"argumentDefinitions": (v0/*: any*/),
|
||||
"kind": "Operation",
|
||||
"name": "VerifyEmailPageMutation",
|
||||
"selections": (v1/*: any*/)
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "c1ea88cfa9a90fed624ad996bbbec2ef",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "VerifyEmailPageMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation VerifyEmailPageMutation(\n $input: VerifyEmailInput!\n) {\n verifyEmail(input: $input) {\n success\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "3e4812eb6e13aa35849bd929b26268b0";
|
||||
|
||||
export default node;
|
||||
135
apps/console/src/pages/iam/auth/VerifyEmailPage.tsx
Normal file
135
apps/console/src/pages/iam/auth/VerifyEmailPage.tsx
Normal file
@@ -0,0 +1,135 @@
|
||||
import { usePageTitle } from "@probo/hooks";
|
||||
import { useTranslate } from "@probo/i18n";
|
||||
import { Button, Field, useToast } from "@probo/ui";
|
||||
import { Link, useSearchParams } from "react-router";
|
||||
import { useFormWithSchema } from "/hooks/useFormWithSchema";
|
||||
import z from "zod";
|
||||
import { useState } from "react";
|
||||
import { graphql } from "relay-runtime";
|
||||
import { useMutation } from "react-relay";
|
||||
import { formatError } from "@probo/helpers";
|
||||
import type { VerifyEmailPageMutation } from "/__generated__/iam/VerifyEmailPageMutation.graphql";
|
||||
|
||||
const verifyEmailMutation = graphql`
|
||||
mutation VerifyEmailPageMutation($input: VerifyEmailInput!) {
|
||||
verifyEmail(input: $input) {
|
||||
success
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const confirmEmailSchema = z.object({
|
||||
token: z.string().min(1, "Please enter a confirmation token"),
|
||||
});
|
||||
|
||||
export default function VerifyEmailPage() {
|
||||
const { __ } = useTranslate();
|
||||
const { toast } = useToast();
|
||||
const [searchParams] = useSearchParams();
|
||||
|
||||
usePageTitle(__("Confirm Email"));
|
||||
|
||||
const [isConfirmed, setIsConfirmed] = useState(false);
|
||||
|
||||
const form = useFormWithSchema(confirmEmailSchema, {
|
||||
defaultValues: {
|
||||
token: searchParams.get("token") ?? "",
|
||||
},
|
||||
});
|
||||
|
||||
const [verifyEmail] =
|
||||
useMutation<VerifyEmailPageMutation>(verifyEmailMutation);
|
||||
|
||||
const handleSubmit = form.handleSubmit(async (data) => {
|
||||
verifyEmail({
|
||||
variables: {
|
||||
input: {
|
||||
token: data.token.trim(),
|
||||
},
|
||||
},
|
||||
onCompleted: (_, errors) => {
|
||||
if (errors) {
|
||||
toast({
|
||||
title: __("Error"),
|
||||
description: formatError(__("Failed to confirm email"), errors),
|
||||
variant: "error",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
setIsConfirmed(true);
|
||||
toast({
|
||||
title: __("Success"),
|
||||
description: __("Your email has been confirmed successfully"),
|
||||
variant: "success",
|
||||
});
|
||||
},
|
||||
onError: (err) => {
|
||||
toast({
|
||||
title: __("Error"),
|
||||
description: err.message || __("Failed to confirm email"),
|
||||
variant: "error",
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="space-y-6 w-full max-w-md mx-auto">
|
||||
<div className="space-y-2 text-center">
|
||||
<h1 className="text-3xl font-bold">{__("Email Confirmation")}</h1>
|
||||
<p className="text-txt-tertiary">
|
||||
{__("Confirm your email address to complete registration")}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{isConfirmed ? (
|
||||
<div className="space-y-4 text-center">
|
||||
<p className="text-green-600 dark:text-green-400">
|
||||
{__("Your email has been confirmed successfully!")}
|
||||
</p>
|
||||
<Button to="/auth/login" className="w-full">
|
||||
{__("Proceed to Login")}
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
<form onSubmit={handleSubmit} className="space-y-4">
|
||||
<Field
|
||||
label={__("Confirmation Token")}
|
||||
type="text"
|
||||
placeholder={__("Enter your confirmation token")}
|
||||
{...form.register("token")}
|
||||
error={form.formState.errors.token?.message}
|
||||
disabled={form.formState.isSubmitting}
|
||||
help={__(
|
||||
"The token has been automatically filled from the URL if available",
|
||||
)}
|
||||
/>
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
className="w-full"
|
||||
disabled={form.formState.isSubmitting}
|
||||
>
|
||||
{form.formState.isSubmitting
|
||||
? __("Confirming...")
|
||||
: __("Confirm Email")}
|
||||
</Button>
|
||||
</form>
|
||||
)}
|
||||
|
||||
<div className="text-center">
|
||||
{!isConfirmed && (
|
||||
<p className="text-sm text-txt-tertiary">
|
||||
<Link
|
||||
to="/auth/login"
|
||||
className="underline text-txt-primary hover:text-txt-secondary"
|
||||
>
|
||||
{__("Back to Login")}
|
||||
</Link>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -46,9 +46,11 @@ export default function SignUpPage() {
|
||||
const onSubmit = (data: FormData) => {
|
||||
signUp({
|
||||
variables: {
|
||||
email: data.email,
|
||||
password: data.password,
|
||||
fullName: data.fullName,
|
||||
input: {
|
||||
email: data.email,
|
||||
password: data.password,
|
||||
fullName: data.fullName,
|
||||
},
|
||||
},
|
||||
onCompleted: (_, e) => {
|
||||
if (e) {
|
||||
|
||||
@@ -67,7 +67,7 @@ export function NewSAMLConfigurationForm(props: { onCreate: () => void }) {
|
||||
},
|
||||
connections: [connectionID],
|
||||
},
|
||||
onCompleted: (response, e) => {
|
||||
onCompleted: (_, e) => {
|
||||
if (e) {
|
||||
toast({
|
||||
variant: "error",
|
||||
|
||||
@@ -81,10 +81,10 @@ const routes = [
|
||||
path: "register",
|
||||
Component: lazy(() => import("./pages/iam/auth/sign-up/SignUpPage")),
|
||||
},
|
||||
// {
|
||||
// path: "confirm-email",
|
||||
// Component: lazy(() => import("./pages/auth/ConfirmEmailPage")),
|
||||
// },
|
||||
{
|
||||
path: "verify-email",
|
||||
Component: lazy(() => import("./pages/iam/auth/VerifyEmailPage")),
|
||||
},
|
||||
{
|
||||
path: "signup-from-invitation",
|
||||
Component: lazy(
|
||||
|
||||
@@ -92,7 +92,7 @@ func (s AccountService) ChangeEmail(ctx context.Context, identityID gid.GID, req
|
||||
}
|
||||
|
||||
confirmationUrl := base.
|
||||
WithPath("/auth/confirm-email").
|
||||
WithPath("/auth/verify-email").
|
||||
WithQuery("token", confirmationToken).
|
||||
MustString()
|
||||
|
||||
|
||||
@@ -349,7 +349,7 @@ func (s AuthService) CreateIdentityWithPassword(
|
||||
}
|
||||
|
||||
confirmationUrl, err := base.
|
||||
WithPath("/auth/confirm-email").
|
||||
WithPath("/auth/verify-email").
|
||||
WithQuery("token", confirmationToken).
|
||||
String()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user