Fix for when user changes their own password, and thus the password in the cookie is no longer valid

This commit is contained in:
Deon George 2023-04-13 21:01:15 +10:00
parent 9207d4e698
commit 36a985554d
4 changed files with 116 additions and 96 deletions

View File

@ -4,11 +4,12 @@ namespace App\Classes\LDAP;
use Carbon\Carbon;
use Exception;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Cookie;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Session;
use LdapRecord\LdapRecordException;
use LdapRecord\Models\Model;
use LdapRecord\Query\Collection as LDAPCollection;
@ -164,6 +165,16 @@ final class Server
} catch (LdapRecordException $e) {
switch ($e->getDetailedError()->getErrorCode()) {
case 49:
// Since we failed authentication, we should delete our auth cookie
if (Cookie::has('password_encrypt')) {
Log::alert('Clearing user credentials and logging out');
Cookie::queue(Cookie::forget('password_encrypt'));
Cookie::queue(Cookie::forget('username_encrypt'));
Session::invalidate();
}
abort(401,$e->getDetailedError()->getErrorMessage());
default:

View File

@ -22,7 +22,7 @@
<div class="modal-body">
<div class="text-center">
<span class="badge badge-danger fsize-2 mb-3 ">@yield('error')</span>
<span class="badge text-danger fsize-2 mb-3">@yield('error')</span>
</div>
<table class="table">
<tr>

View File

@ -0,0 +1,9 @@
@extends('architect::layouts.error')
@section('error')
401: @lang('LDAP Authentication Error')
@endsection
@section('content')
{{ $exception->getMessage() }}
@endsection

View File

@ -1,7 +1,7 @@
@extends('architect::layouts.error')
@section('error')
@lang('LDAP Server Unavailable')
597: @lang('LDAP Server Unavailable')
@endsection
@section('content')