Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/app/(auth)/forgot-password/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import ForgotPasswordForm from 'module/auth/forgot-password-form/forgot-password-form.component';

const ForgotPassword = () => {
return <ForgotPasswordForm />;
};

export default ForgotPassword;
7 changes: 7 additions & 0 deletions src/app/(auth)/reset-password/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import ResetPasswordForm from 'module/auth/reset-password-form/reset-password-form.component';

const ResetPassword = () => {
return <ResetPasswordForm />;
};

export default ResetPassword;
20 changes: 20 additions & 0 deletions src/graphql/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,23 @@ export const USER_REGISTER = gql(`
}
}
`);

export const USER_FORGOT_PASSWORD = gql(`
mutation ForgotPassword($email: String!){
forgotPassword(email: $email) {
code
message
data
}
}
`);

export const USER_RESET_PASSWORD = gql(`
mutation resetPassword($input: ResetPasswordInput!){
resetPassword(input: $input) {
code
message
data
}
}
`);
16 changes: 16 additions & 0 deletions src/graphql/codegen/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ const documents = {
types.LoginDocument,
'\n mutation Register($input: CreateUserInput!) {\n register(input: $input) {\n code\n message\n data\n }\n }\n':
types.RegisterDocument,
'\n mutation ForgotPassword($email: String!){\n forgotPassword(email: $email) {\n code\n message\n data\n }\n }\n':
types.ForgotPasswordDocument,
'\n mutation resetPassword($input: ResetPasswordInput!){\n resetPassword(input: $input) {\n code\n message\n data\n }\n }\n':
types.ResetPasswordDocument,
'\n query getUserInfo {\n getUserInfo {\n id\n displayName\n }\n }\n':
types.GetUserInfoDocument,
'\n query getUserById($id: String!) {\n getUserById(id: $id) {\n id\n email\n realName\n displayName\n mobile\n }\n }\n':
Expand Down Expand Up @@ -51,6 +55,18 @@ export function gql(
export function gql(
source: '\n mutation Register($input: CreateUserInput!) {\n register(input: $input) {\n code\n message\n data\n }\n }\n'
): (typeof documents)['\n mutation Register($input: CreateUserInput!) {\n register(input: $input) {\n code\n message\n data\n }\n }\n'];
/**
* The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function gql(
source: '\n mutation ForgotPassword($email: String!){\n forgotPassword(email: $email) {\n code\n message\n data\n }\n }\n'
): (typeof documents)['\n mutation ForgotPassword($email: String!){\n forgotPassword(email: $email) {\n code\n message\n data\n }\n }\n'];
/**
* The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function gql(
source: '\n mutation resetPassword($input: ResetPasswordInput!){\n resetPassword(input: $input) {\n code\n message\n data\n }\n }\n'
): (typeof documents)['\n mutation resetPassword($input: ResetPasswordInput!){\n resetPassword(input: $input) {\n code\n message\n data\n }\n }\n'];
/**
* The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
Expand Down
152 changes: 152 additions & 0 deletions src/graphql/codegen/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,20 @@ export type Mutation = {
deleteUser: Scalars['Boolean']['output'];
/** Hard delete an user key */
deleteUserKey: Scalars['Boolean']['output'];
/** Forgot password */
forgotPassword: Result;
/** User login */
login: Result;
/** User register */
register: Result;
/** Reset password */
resetPassword: Result;
/** Update exchange key info */
updateExchangeKey: Scalars['Boolean']['output'];
/** Update user info */
updateUser: Scalars['Boolean']['output'];
/** Email Verification */
verifyEmail: Result;
};

export type MutationChangePasswordArgs = {
Expand All @@ -105,6 +111,10 @@ export type MutationDeleteUserArgs = {
id: Scalars['String']['input'];
};

export type MutationForgotPasswordArgs = {
email: Scalars['String']['input'];
};

export type MutationLoginArgs = {
email: Scalars['String']['input'];
password: Scalars['String']['input'];
Expand All @@ -114,6 +124,10 @@ export type MutationRegisterArgs = {
input: CreateUserInput;
};

export type MutationResetPasswordArgs = {
input: ResetPasswordInput;
};

export type MutationUpdateExchangeKeyArgs = {
input: UpdateExchangeKeyInput;
};
Expand All @@ -123,6 +137,11 @@ export type MutationUpdateUserArgs = {
input: UpdateUserInput;
};

export type MutationVerifyEmailArgs = {
email: Scalars['String']['input'];
token: Scalars['String']['input'];
};

export type Query = {
__typename?: 'Query';
/** Find exchange key by id */
Expand All @@ -149,6 +168,13 @@ export type QueryGetUserByIdArgs = {
id: Scalars['String']['input'];
};

export type ResetPasswordInput = {
/** New Password */
newPassword: Scalars['String']['input'];
/** Reset Token */
resetToken: Scalars['String']['input'];
};

export type Result = {
__typename?: 'Result';
code: Scalars['Int']['output'];
Expand Down Expand Up @@ -177,6 +203,8 @@ export type UpdatePasswordInput = {
export type UpdateUserInput = {
/** User display name */
displayName?: InputMaybe<Scalars['String']['input']>;
/** is Email Verified */
isEmailVerified?: InputMaybe<Scalars['Boolean']['input']>;
/** Mobile number */
mobile?: InputMaybe<Scalars['String']['input']>;
/** Password */
Expand All @@ -185,6 +213,8 @@ export type UpdateUserInput = {
realName?: InputMaybe<Scalars['String']['input']>;
/** User is referred by */
ref?: InputMaybe<Scalars['String']['input']>;
/** Verification Token */
verificationToken?: InputMaybe<Scalars['String']['input']>;
};

export type UserType = {
Expand All @@ -195,6 +225,8 @@ export type UserType = {
email: Scalars['String']['output'];
/** User ID */
id: Scalars['String']['output'];
/** is Email Verified */
isEmailVerified: Scalars['Boolean']['output'];
/** Mobile number */
mobile: Scalars['String']['output'];
/** QQ */
Expand All @@ -203,6 +235,10 @@ export type UserType = {
realName: Scalars['String']['output'];
/** User is referred by */
ref: Scalars['String']['output'];
/** Reset Password Token */
resetPasswordToken?: Maybe<Scalars['String']['output']>;
/** Verification Token */
verificationToken?: Maybe<Scalars['String']['output']>;
/** Wechat */
wechat: Scalars['String']['output'];
};
Expand All @@ -226,6 +262,34 @@ export type RegisterMutation = {
register: { __typename?: 'Result'; code: number; message?: string | null; data?: string | null };
};

export type ForgotPasswordMutationVariables = Exact<{
email: Scalars['String']['input'];
}>;

export type ForgotPasswordMutation = {
__typename?: 'Mutation';
forgotPassword: {
__typename?: 'Result';
code: number;
message?: string | null;
data?: string | null;
};
};

export type ResetPasswordMutationVariables = Exact<{
input: ResetPasswordInput;
}>;

export type ResetPasswordMutation = {
__typename?: 'Mutation';
resetPassword: {
__typename?: 'Result';
code: number;
message?: string | null;
data?: string | null;
};
};

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

export type GetUserInfoQuery = {
Expand Down Expand Up @@ -357,6 +421,94 @@ export const RegisterDocument = {
},
],
} as unknown as DocumentNode<RegisterMutation, RegisterMutationVariables>;
export const ForgotPasswordDocument = {
kind: 'Document',
definitions: [
{
kind: 'OperationDefinition',
operation: 'mutation',
name: { kind: 'Name', value: 'ForgotPassword' },
variableDefinitions: [
{
kind: 'VariableDefinition',
variable: { kind: 'Variable', name: { kind: 'Name', value: 'email' } },
type: {
kind: 'NonNullType',
type: { kind: 'NamedType', name: { kind: 'Name', value: 'String' } },
},
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'forgotPassword' },
arguments: [
{
kind: 'Argument',
name: { kind: 'Name', value: 'email' },
value: { kind: 'Variable', name: { kind: 'Name', value: 'email' } },
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{ kind: 'Field', name: { kind: 'Name', value: 'code' } },
{ kind: 'Field', name: { kind: 'Name', value: 'message' } },
{ kind: 'Field', name: { kind: 'Name', value: 'data' } },
],
},
},
],
},
},
],
} as unknown as DocumentNode<ForgotPasswordMutation, ForgotPasswordMutationVariables>;
export const ResetPasswordDocument = {
kind: 'Document',
definitions: [
{
kind: 'OperationDefinition',
operation: 'mutation',
name: { kind: 'Name', value: 'resetPassword' },
variableDefinitions: [
{
kind: 'VariableDefinition',
variable: { kind: 'Variable', name: { kind: 'Name', value: 'input' } },
type: {
kind: 'NonNullType',
type: { kind: 'NamedType', name: { kind: 'Name', value: 'ResetPasswordInput' } },
},
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'resetPassword' },
arguments: [
{
kind: 'Argument',
name: { kind: 'Name', value: 'input' },
value: { kind: 'Variable', name: { kind: 'Name', value: 'input' } },
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{ kind: 'Field', name: { kind: 'Name', value: 'code' } },
{ kind: 'Field', name: { kind: 'Name', value: 'message' } },
{ kind: 'Field', name: { kind: 'Name', value: 'data' } },
],
},
},
],
},
},
],
} as unknown as DocumentNode<ResetPasswordMutation, ResetPasswordMutationVariables>;
export const GetUserInfoDocument = {
kind: 'Document',
definitions: [
Expand Down
6 changes: 5 additions & 1 deletion src/hooks/userHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ export const useLoadUser = () => {
refetchHandler: refetch,
});
console.error('failed retrieving user info, backing to login');
if (!pathName.match('/login') && typeof window !== 'undefined') {
if (
!pathName.match('/login') &&
!pathName.match('/reset-password') &&
typeof window !== 'undefined'
) {
router.push(`/login?orgUrl=${pathName}`);
}
},
Expand Down
Loading