Skip to content

Commit

Permalink
Reset Password Fix (#353)
Browse files Browse the repository at this point in the history
* feat(errors): added email error to common error list

* fix(server): return reset password mutation

* fix(internal error): implemented abstract class for password reset mutation response
  • Loading branch information
kadey001 committed Dec 8, 2022
1 parent 4058c53 commit be38ee7
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 67 deletions.
7 changes: 6 additions & 1 deletion app/client/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ type Mutation {
prevQuestion(eventId: ID!): Event!
register(input: RegistrationForm!): UserMutationResponse!
removeQuestionFromQueue(input: RemoveQuestionFromQueue!): EventQuestionMutationResponse!
resetPassword(input: ResetPasswordForm!): MutationResponse!
resetPassword(input: ResetPasswordForm!): ResetPasswordMutationResponse!

"""
send a reset password request if the account exists
Expand Down Expand Up @@ -597,6 +597,11 @@ input ResetPasswordForm {
token: String!
}

type ResetPasswordMutationResponse implements MutationResponse {
isError: Boolean!
message: String!
}

input ResetPasswordRequestForm {
email: String!
}
Expand Down
93 changes: 35 additions & 58 deletions app/client/src/__generated__/PasswordResetFormMutation.graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion app/client/src/graphql-types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions app/server/src/features/accounts/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ export const resolvers: Resolvers = {
},
async resetPassword(parent, args, ctx, info) {
return runMutation(async () => {
// No need to return anything, a no error response is fine
// since the user will simply be redirected to login after resetting
await User.resetPassword(ctx.prisma, args.input);
return User.resetPassword(ctx.prisma, args.input);
});
},
async deleteAccount(parent, args, ctx, info) {
Expand Down
7 changes: 6 additions & 1 deletion app/server/src/features/accounts/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ type ResetPasswordRequestMutationResponse implements MutationResponse {
body: Boolean
}

type ResetPasswordMutationResponse implements MutationResponse {
isError: Boolean!
message: String!
}

type ValidatePasswordResetTokenQueryResponse {
valid: Boolean!
message: String!
Expand All @@ -123,7 +128,7 @@ type Mutation {
returns false if an account with the provided email cannot be found
"""
resetPasswordRequest(input: ResetPasswordRequestForm!): ResetPasswordRequestMutationResponse!
resetPassword(input: ResetPasswordForm!): MutationResponse!
resetPassword(input: ResetPasswordForm!): ResetPasswordMutationResponse!
deleteAccount(input: DeleteAccountForm!): UserMutationResponse!
"""
The logout just returns the timestamp of the logout action
Expand Down
2 changes: 1 addition & 1 deletion app/server/src/features/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const errors = {
fileNotFound: 'File not found',
fileSize: 'File too large',
email: 'Emailed failed to send due to an unexpected error',
jwt: 'Invalid Token'
jwt: 'Invalid Token',
};
interface TFilterFieldArgs<TObj extends Record<string, unknown>, TKeys extends keyof TObj> {
input: TObj;
Expand Down
30 changes: 28 additions & 2 deletions app/server/src/graphql-types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit be38ee7

Please sign in to comment.