1
0
mirror of https://github.com/freescout-helpdesk/freescout.git synced 2025-01-31 20:11:38 +01:00

Login hooks

This commit is contained in:
FreeScout 2023-07-15 06:11:45 -07:00
parent 9b6fa32db5
commit ffe2adc4c2
2 changed files with 41 additions and 1 deletions

View File

@ -2,8 +2,10 @@
namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Validation\ValidationException;
class LoginController extends Controller
{
@ -38,4 +40,40 @@ class LoginController extends Controller
{
$this->middleware('guest')->except('logout');
}
/**
* Handle a login request to the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response|\Illuminate\Http\JsonResponse
*/
public function login(Request $request)
{
$this->validateLogin($request);
// If the class is using the ThrottlesLogins trait, we can automatically throttle
// the login attempts for this application. We'll key this by the username and
// the IP address of the client making these requests into this application.
if ($this->hasTooManyLoginAttempts($request)) {
$this->fireLockoutEvent($request);
return $this->sendLockoutResponse($request);
}
$custom_errors = \Eventy::filter('login.custom_check', [], $request);
if ($custom_errors) {
throw ValidationException::withMessages($custom_errors);
}
if ($this->attemptLogin($request)) {
return $this->sendLoginResponse($request);
}
// If the login attempt was unsuccessful we will increment the number of attempts
// to login and redirect the user back to the login form. Of course, when this
// user surpasses their maximum number of attempts they will get locked out.
$this->incrementLoginAttempts($request);
return $this->sendFailedLoginResponse($request);
}
}

View File

@ -51,10 +51,12 @@
</label>
</div>
</div>
@action('login_form.before_submit')
<div class="form-group">
<div class="col-md-8 col-md-offset-4">
<button type="submit" class="btn btn-primary">
<button type="submit" class="btn btn-primary @action('login_form.submit_class')" @action('login_form.submit_attrs')>
{{ __('Login') }}
</button>