2017-01-30 20:40:43 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Auth;
|
2015-03-16 22:45:25 +01:00
|
|
|
|
2017-11-01 20:22:29 +01:00
|
|
|
use Event;
|
2017-11-15 10:25:41 +01:00
|
|
|
use Illuminate\Http\Request;
|
2017-11-01 20:22:29 +01:00
|
|
|
use App\Events\UserLoggedIn;
|
2015-03-23 05:20:33 +01:00
|
|
|
use App\Http\Controllers\Controller;
|
2015-03-16 22:45:25 +01:00
|
|
|
use Illuminate\Foundation\Auth\ResetsPasswords;
|
|
|
|
|
2017-11-14 09:58:08 +01:00
|
|
|
class ResetPasswordController extends Controller
|
2016-07-03 18:11:58 +02:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Password Reset Controller
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| This controller is responsible for handling password reset requests
|
|
|
|
| and uses a simple trait to include this behavior. You're free to
|
|
|
|
| explore this trait and override any methods you wish to tweak.
|
|
|
|
|
|
|
|
|
*/
|
2015-03-16 22:45:25 +01:00
|
|
|
|
2017-11-01 20:22:29 +01:00
|
|
|
use ResetsPasswords {
|
2017-11-14 09:58:08 +01:00
|
|
|
sendResetResponse as protected traitSendResetResponse;
|
2017-11-01 20:22:29 +01:00
|
|
|
}
|
2015-03-16 22:45:25 +01:00
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
2017-11-14 09:58:08 +01:00
|
|
|
* Where to redirect users after resetting their password.
|
|
|
|
*
|
2016-07-03 18:11:58 +02:00
|
|
|
* @var string
|
|
|
|
*/
|
2015-03-30 17:20:53 +02:00
|
|
|
protected $redirectTo = '/dashboard';
|
2016-07-03 18:11:58 +02:00
|
|
|
|
|
|
|
/**
|
2017-11-14 09:58:08 +01:00
|
|
|
* Create a new controller instance.
|
2016-07-03 18:11:58 +02:00
|
|
|
*
|
2017-11-14 09:58:08 +01:00
|
|
|
* @return void
|
2016-07-03 18:11:58 +02:00
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->middleware('guest');
|
|
|
|
}
|
2017-09-07 20:51:40 +02:00
|
|
|
|
2017-11-14 09:58:08 +01:00
|
|
|
protected function sendResetResponse($response)
|
2017-11-01 20:22:29 +01:00
|
|
|
{
|
|
|
|
$user = auth()->user();
|
|
|
|
|
|
|
|
if ($user->google_2fa_secret) {
|
|
|
|
auth()->logout();
|
|
|
|
session(['2fa:user:id' => $user->id]);
|
|
|
|
return redirect('/validate_two_factor/' . $user->account->account_key);
|
|
|
|
} else {
|
|
|
|
Event::fire(new UserLoggedIn());
|
2017-11-14 09:58:08 +01:00
|
|
|
return $this->traitSendResetResponse($response);
|
2017-11-01 20:22:29 +01:00
|
|
|
}
|
|
|
|
}
|
2017-11-15 08:51:49 +01:00
|
|
|
|
|
|
|
public function showResetForm(Request $request, $token = null)
|
|
|
|
{
|
|
|
|
return view('auth.passwords.reset')->with(
|
2018-01-10 14:10:49 +01:00
|
|
|
['token' => $token]
|
2017-11-15 08:51:49 +01:00
|
|
|
);
|
|
|
|
}
|
2015-03-16 22:45:25 +01:00
|
|
|
}
|