Skip to content

Commit

Permalink
fix resend email verification in auth
Browse files Browse the repository at this point in the history
  • Loading branch information
nxtcoder19 committed Jun 25, 2024
1 parent 3f43f46 commit 4ac600b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
4 changes: 4 additions & 0 deletions gql-queries-generator/doc/queries.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6485,6 +6485,10 @@ mutation authVerifyEmail($token: String!) {
}
}

mutation authResendVerificationEmail {
auth_resendVerificationEmail
}

query authLoginPageInitUrls {
githubLoginUrl: oAuth_requestLogin(provider: "github")
gitlabLoginUrl: oAuth_requestLogin(provider: "gitlab")
Expand Down
8 changes: 4 additions & 4 deletions src/apps/auth/routes/_main+/verify-email.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useAPIClient } from '~/root/lib/client/hooks/api-provider';
import usePersistState from '~/root/lib/client/hooks/use-persist-state';
import { useEffect, useState } from 'react';
import { GQLServerHandler } from '~/auth/server/gql/saved-queries';
Expand All @@ -14,20 +13,21 @@ import { IRemixCtx } from '~/root/lib/types/common';
import { ArrowLeft } from '~/components/icons';
import { cn } from '~/components/utils';
import Container from '~/auth/components/container';
import { useAuthApi } from '~/auth/server/gql/api-provider';

const VerifyEmail = () => {
const { query, email } = useLoaderData();
const navigate = useNavigate();
const { token } = query;
const api = useAPIClient();
const api = useAuthApi();

const [rateLimiter, setRateLimiter] = usePersistState('rateLimiter', {});

useEffect(() => {
(async () => {
try {
if (!token) return;
const { _, errors } = await api.verifyEmail({
const { errors } = await api.verifyEmail({
token,
});
if (errors) {
Expand Down Expand Up @@ -68,7 +68,7 @@ const VerifyEmail = () => {

setSending(true);

const { errors } = await api.resendVerificationEmail({ email });
const { errors } = await api.resendVerificationEmail();

setSending(false);

Expand Down
15 changes: 15 additions & 0 deletions src/apps/auth/server/gql/saved-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import {
AuthCheckOauthEnabledQueryVariables,
AuthSetRemoteAuthHeaderMutation,
AuthSetRemoteAuthHeaderMutationVariables,
AuthResendVerificationEmailMutation,
AuthResendVerificationEmailMutationVariables,
} from '~/root/src/generated/gql/server';
import { cliQueries } from './cli-queries';

Expand Down Expand Up @@ -138,6 +140,19 @@ export const GQLServerHandler = ({ headers, cookies }: IGQLServerProps) => {
}
),

resendVerificationEmail: executor(
gql`
mutation Mutation {
auth_resendVerificationEmail
}
`,
{
transformer: (data: AuthResendVerificationEmailMutation) =>
data.auth_resendVerificationEmail,
vars(_: AuthResendVerificationEmailMutationVariables) {},
}
),

loginPageInitUrls: executor(
gql`
query Query {
Expand Down
8 changes: 8 additions & 0 deletions src/generated/gql/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8117,6 +8117,14 @@ export type AuthVerifyEmailMutationVariables = Exact<{

export type AuthVerifyEmailMutation = { auth_verifyEmail: { id: string } };

export type AuthResendVerificationEmailMutationVariables = Exact<{
[key: string]: never;
}>;

export type AuthResendVerificationEmailMutation = {
auth_resendVerificationEmail: boolean;
};

export type AuthLoginPageInitUrlsQueryVariables = Exact<{
[key: string]: never;
}>;
Expand Down

0 comments on commit 4ac600b

Please sign in to comment.