Skip to content

Commit

Permalink
[Updated: forgot password email warning message changed.]
Browse files Browse the repository at this point in the history
  • Loading branch information
vivek-webkul committed Dec 9, 2022
1 parent ce07dc6 commit 42e05a1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
27 changes: 22 additions & 5 deletions src/Mutations/Shop/Customer/ForgotPasswordMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Webkul\GraphQLAPI\Mutations\Shop\Customer;

use Exception;
use Illuminate\Http\JsonResponse;
use Webkul\GraphQLAPI\Validators\Customer\CustomException;
use Webkul\Customer\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
use Illuminate\Support\Facades\Password;
Expand Down Expand Up @@ -52,7 +52,15 @@ public function forgot($rootValue, array $args , GraphQLContext $context)
]);

if ($validator->fails()) {
throw new Exception($validator->messages());
$errorMessage = [];
foreach ($validator->messages()->toArray() as $message) {
$errorMessage[] = is_array($message) ? $message[0] : $message;
}

throw new CustomException(
implode(" ,", $errorMessage),
'Invalid ForgotPassword Details.'
);
}

try {
Expand All @@ -64,12 +72,21 @@ public function forgot($rootValue, array $args , GraphQLContext $context)
'success' => trans('customer::app.forget_password.reset_link_sent')
];
} else {
throw new Exception(trans('bagisto_graphql::app.shop.response.password-reset-failed'));
throw new CustomException(
trans('bagisto_graphql::app.shop.response.password-reset-failed'),
'Invalid ForgotPassword Email Details.'
);
}
} catch (\Swift_RfcComplianceException $e) {
throw new Exception(trans('customer::app.forget_password.reset_link_sent'));
throw new CustomException(
trans('customer::app.forget_password.reset_link_sent'),
'Swift_RfcComplianceException: Invalid ForgotPassword Details.'
);
} catch (Exception $e) {
throw new Exception($e->getMessage());
throw new CustomException(
$e->getMessage(),
'Exception: invalid forgot password email.'
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Resources/lang/en/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
],
'response' => [
'error-registration' => 'Warning: customer registration failed.',
'password-reset-failed' => 'Warning: there is some error in sending password reset email.',
'password-reset-failed' => 'Warning: We already sent you password reset email, try after sometime.',
'customer-details' => 'Success: Customer details fetched successfully.',
'not-found' => 'Wanring: No :name found.',
'no-address-found' => 'Wanring: No address found.',
Expand Down

0 comments on commit 42e05a1

Please sign in to comment.