From 44ae338276bd27908ccb80565d12f223fb32e9ce Mon Sep 17 00:00:00 2001 From: Purvesh Date: Fri, 3 Feb 2023 11:53:42 +1300 Subject: [PATCH] added validation in reset password mutation --- src/Graphql/Mutations/Auth/LoginMutation.php | 4 ++-- .../Mutations/Auth/ResetPasswordMutation.php | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Graphql/Mutations/Auth/LoginMutation.php b/src/Graphql/Mutations/Auth/LoginMutation.php index 962d0e5b..06a1d131 100644 --- a/src/Graphql/Mutations/Auth/LoginMutation.php +++ b/src/Graphql/Mutations/Auth/LoginMutation.php @@ -47,8 +47,8 @@ public function __construct( protected function rules(array $rules = []): array { return [ - 'email' => ['required', 'max:255'], - 'password' => ['required', 'max:255'] + 'email' => ['required', 'max:255', 'email'], + 'password' => ['required', 'max:64'] ]; } diff --git a/src/Graphql/Mutations/Auth/ResetPasswordMutation.php b/src/Graphql/Mutations/Auth/ResetPasswordMutation.php index 53bbda03..c3a2e4c7 100644 --- a/src/Graphql/Mutations/Auth/ResetPasswordMutation.php +++ b/src/Graphql/Mutations/Auth/ResetPasswordMutation.php @@ -65,7 +65,6 @@ public function args(): array public function resolve($root, $args, $context, ResolveInfo $resolveInfo, Closure $getSelectFields) { - $response = $this->broker()->reset($args, function ($user, $password) { $this->resetPassword($user, $password); } @@ -91,6 +90,22 @@ public function broker() return Password::broker('customers'); } + + /** + * Setup the Validation rules for login mutation + * + * @return array $rules + */ + protected function rules(array $rules = []): array + { + return [ + 'token' => 'required', + 'email' => 'required|email', + 'password' => 'required|confirmed|min:6', + ]; + } + + /** * Reset the given user's password. *