2016-12-14 05:06:15 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Auth;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
class ForgotPasswordController extends Controller
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Password Reset Controller
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| This controller is responsible for handling password reset emails and
|
|
|
|
| includes a trait which assists in sending these notifications from
|
|
|
|
| your application to your users. Feel free to explore this trait.
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
use SendsPasswordResetEmails;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new controller instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->middleware('guest');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the e-mail subject line to be used for the reset link email.
|
|
|
|
* Overriding method "getEmailSubject()" from trait "use ResetsPasswords"
|
|
|
|
* @return string
|
|
|
|
*/
|
2016-12-29 14:02:18 -08:00
|
|
|
public function getEmailSubject()
|
|
|
|
{
|
2016-12-14 05:06:15 -08:00
|
|
|
return property_exists($this, 'subject') ? $this->subject : \Lang::get('mail.reset_link');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send a reset link to the given user.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
|
|
*/
|
|
|
|
public function sendResetLinkEmail(Request $request)
|
|
|
|
{
|
2018-10-31 18:03:24 -07:00
|
|
|
$this->validate($request, ['username' => 'required'], ['username.required' => 'Please enter your username.']);
|
2016-12-14 05:06:15 -08:00
|
|
|
|
2018-10-31 18:03:24 -07:00
|
|
|
|
|
|
|
// Make sure the user is active, and their password is not controlled via LDAP
|
2016-12-14 05:06:15 -08:00
|
|
|
$response = $this->broker()->sendResetLink(
|
2018-08-14 18:04:27 -07:00
|
|
|
array_merge(
|
2018-10-31 18:03:24 -07:00
|
|
|
$request->only('username'),
|
|
|
|
['activated' => '1'],
|
|
|
|
['ldap_import' => '0']
|
2018-08-14 18:04:27 -07:00
|
|
|
)
|
2016-12-14 05:06:15 -08:00
|
|
|
);
|
|
|
|
|
|
|
|
if ($response === \Password::RESET_LINK_SENT) {
|
2018-10-31 18:03:24 -07:00
|
|
|
\Log::info('Password reset attempt: User '.$request->input('username').' found, password reset sent');
|
|
|
|
} else {
|
|
|
|
\Log::info('Password reset attempt: User '.$request->input('username').' not found or user is inactive');
|
2016-12-14 05:06:15 -08:00
|
|
|
}
|
|
|
|
|
2018-10-31 18:03:24 -07:00
|
|
|
|
|
|
|
|
|
|
|
// Regardless of response, we do not want to disclose the status of a user account,
|
|
|
|
// so we give them a generic "If this exists, we're TOTALLY gonna email you" response
|
|
|
|
return redirect()->route('login')->with('success',trans('passwords.sent'));
|
2016-12-14 05:06:15 -08:00
|
|
|
}
|
|
|
|
}
|