From 16220c656ff01014de4742eeb6e1d62246232b37 Mon Sep 17 00:00:00 2001 From: jitendra Date: Wed, 8 May 2019 18:56:28 +0530 Subject: [PATCH] Added api for forgot password --- .../Shop/ForgotPasswordController.php | 51 +++++++++++++++++++ .../API/Http/Resources/Core/Channel.php | 1 + packages/Webkul/API/Http/routes.php | 2 + 3 files changed, 54 insertions(+) create mode 100644 packages/Webkul/API/Http/Controllers/Shop/ForgotPasswordController.php diff --git a/packages/Webkul/API/Http/Controllers/Shop/ForgotPasswordController.php b/packages/Webkul/API/Http/Controllers/Shop/ForgotPasswordController.php new file mode 100644 index 000000000..50529541e --- /dev/null +++ b/packages/Webkul/API/Http/Controllers/Shop/ForgotPasswordController.php @@ -0,0 +1,51 @@ + + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ +class ForgotPasswordController extends Controller +{ + use SendsPasswordResetEmails; + + /** + * Store a newly created resource in storage. + * + * @return \Illuminate\Http\Response + */ + public function store() + { + $this->validate(request(), [ + 'email' => 'required|email' + ]); + + $response = $this->broker()->sendResetLink(request(['email'])); + + if ($response == Password::RESET_LINK_SENT) { + return response()->json([ + 'message' => trans($response) + ]); + } + + return response()->json([ + 'error' => trans($response) + ]); + } + + /** + * Get the broker to be used during password reset. + * + * @return \Illuminate\Contracts\Auth\PasswordBroker + */ + public function broker() + { + return Password::broker('customers'); + } +} \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Core/Channel.php b/packages/Webkul/API/Http/Resources/Core/Channel.php index e80393075..e85085ce0 100644 --- a/packages/Webkul/API/Http/Resources/Core/Channel.php +++ b/packages/Webkul/API/Http/Resources/Core/Channel.php @@ -33,6 +33,7 @@ class Channel extends JsonResource 'favicon_url' => $this->favicon_url, 'default_locale' => $this->when($this->default_locale_id, new LocaleResource($this->default_locale)), 'base_currency' => $this->when($this->default_currency_id, new CurrencyResource($this->default_currency)), + 'root_category_id' => $this->root_category_id, 'root_category' => $this->when($this->root_category_id, new CategoryResource($this->root_category)), 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, diff --git a/packages/Webkul/API/Http/routes.php b/packages/Webkul/API/Http/routes.php index f825d6ff3..6d0917c9a 100755 --- a/packages/Webkul/API/Http/routes.php +++ b/packages/Webkul/API/Http/routes.php @@ -138,6 +138,8 @@ Route::group(['prefix' => 'api'], function ($router) { //Customer routes Route::post('customer/login', 'SessionController@create'); + Route::post('customer/forgot-password', 'ForgotPasswordController@store'); + Route::get('customer/logout', 'SessionController@destroy'); Route::get('customer/get', 'SessionController@get');