2018-10-10 10:41:33 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Webkul\Customer\Http\Controllers;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
|
|
|
|
use Illuminate\Support\Facades\Password;
|
|
|
|
|
|
2018-10-27 11:13:57 +00:00
|
|
|
/**
|
|
|
|
|
* Forgot Password controlller for the customer.
|
|
|
|
|
*
|
|
|
|
|
* @author Prashant Singh <prashant.singh852@webkul.com>
|
|
|
|
|
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
|
|
|
|
*/
|
2018-10-10 10:41:33 +00:00
|
|
|
class ForgotPasswordController extends Controller
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
use SendsPasswordResetEmails;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Contains route related configuration
|
|
|
|
|
*
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
|
|
|
|
protected $_config;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new controller instance.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
$this->_config = request('_config');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Show the form for creating a new resource.
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
|
*/
|
|
|
|
|
public function create()
|
|
|
|
|
{
|
|
|
|
|
return view($this->_config['view']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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'])
|
|
|
|
|
);
|
2019-07-01 11:33:36 +00:00
|
|
|
|
2019-01-15 11:54:41 +00:00
|
|
|
if ($response == Password::RESET_LINK_SENT) {
|
2018-10-10 10:41:33 +00:00
|
|
|
session()->flash('success', trans($response));
|
|
|
|
|
|
|
|
|
|
return back();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return back()
|
|
|
|
|
->withInput(request(['email']))
|
|
|
|
|
->withErrors(
|
|
|
|
|
['email' => trans($response)]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the broker to be used during password reset.
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Contracts\Auth\PasswordBroker
|
|
|
|
|
*/
|
|
|
|
|
public function broker()
|
|
|
|
|
{
|
|
|
|
|
return Password::broker('customers');
|
|
|
|
|
}
|
|
|
|
|
}
|