sarga/packages/Webkul/Customer/src/Http/Controllers/ForgotPasswordController.php

84 lines
1.9 KiB
PHP
Raw Normal View History

2018-10-10 10:41:33 +00:00
<?php
namespace Webkul\Customer\Http\Controllers;
use Illuminate\Support\Facades\Password;
class ForgotPasswordController extends Controller
{
/**
* 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.
*
2019-08-19 09:30:24 +00:00
* @return \Illuminate\View\View
2018-10-10 10:41:33 +00:00
*/
public function create()
{
return view($this->_config['view']);
}
/**
* Store a newly created resource in storage.
*
* @return \Illuminate\Http\Response
*/
public function store()
{
try {
$this->validate(request(), [
2020-03-04 06:32:53 +00:00
'email' => 'required|email',
]);
2018-10-10 10:41:33 +00:00
$response = $this->broker()->sendResetLink(
request(['email'])
);
2018-10-10 10:41:33 +00:00
if ($response == Password::RESET_LINK_SENT) {
session()->flash('success', trans($response));
2018-10-10 10:41:33 +00:00
return back();
}
return back()
->withInput(request(['email']))
2020-03-04 06:32:53 +00:00
->withErrors([
'email' => trans($response),
]);
2020-03-24 14:41:48 +00:00
} catch (\Swift_RfcComplianceException $e) {
session()->flash('success', trans('customer::app.forget_password.reset_link_sent'));
return redirect()->back();
} catch (\Exception $e) {
2020-01-27 16:06:03 +00:00
report($e);
session()->flash('error', trans($e->getMessage()));
return redirect()->back();
}
2018-10-10 10:41:33 +00:00
}
/**
* Get the broker to be used during password reset.
*
* @return \Illuminate\Contracts\Auth\PasswordBroker
*/
public function broker()
{
return Password::broker('customers');
}
}