Added api for forgot password
This commit is contained in:
parent
0ff492ae80
commit
16220c656f
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\API\Http\Controllers\Shop;
|
||||
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
|
||||
/**
|
||||
* Forgot Password controller
|
||||
*
|
||||
* @author Jitendra Singh <jitendra@webkul.com>
|
||||
* @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');
|
||||
}
|
||||
}
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Reference in New Issue