Fix auth controllers for laravel 11
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 30s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m31s
Create Docker Image / Final Docker Image Manifest (push) Successful in 9s

This commit is contained in:
Deon George 2024-11-06 18:43:35 +11:00
parent c2197ecf7c
commit 1075cc0de4
9 changed files with 46 additions and 59 deletions

View File

@ -2,10 +2,9 @@
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\ConfirmsPasswords;
use App\Http\Controllers\Controller;
class ConfirmPasswordController extends Controller
{
/*
@ -26,7 +25,7 @@ class ConfirmPasswordController extends Controller
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
protected $redirectTo = '/';
/**
* Create a new controller instance.

View File

@ -2,11 +2,12 @@
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Password;
use App\Http\Controllers\Controller;
class ForgotPasswordController extends Controller
{
/*

View File

@ -8,7 +8,6 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
class LoginController extends Controller
{
@ -30,7 +29,7 @@ class LoginController extends Controller
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
protected $redirectTo = '/';
/**
* Create a new controller instance.
@ -39,40 +38,41 @@ class LoginController extends Controller
*/
public function __construct()
{
$this->middleware('guest')
->except('logout');
$this->middleware('guest')->except('logout');
$this->middleware('auth')->only('logout');
}
public function login(Request $request)
{
$this->validateLogin($request);
public function login(Request $request)
{
$this->validateLogin($request);
if (Auth::attempt(array_merge($this->credentials($request),['active'=>TRUE]),TRUE)) {
$request->session()->regenerate();
if (Auth::attempt(array_merge($this->credentials($request),['active'=>TRUE]),TRUE)) {
$request->session()->regenerate();
return $this->sendLoginResponse($request);
}
return $this->sendLoginResponse($request);
}
return $this->sendFailedLoginResponse($request);
}
return $this->sendFailedLoginResponse($request);
}
protected function authenticated(Request $request, $user)
{
$user->last_on = Carbon::now();
$user->save();
}
// Record our last logged in time
protected function authenticated(Request $request, $user)
{
$user->last_on = Carbon::now();
$user->save();
}
/**
* Show our themed login page
*/
public function showLoginForm()
{
$login_note = '';
/**
* Show our themed login page
*/
public function showLoginForm()
{
$login_note = '';
if (file_exists('login_note.txt'))
$login_note = file_get_contents('login_note.txt');
if (file_exists('login_note.txt'))
$login_note = file_get_contents('login_note.txt');
return view('auth.login')
->with('login_note',$login_note);
}
return view('auth.login')
->with('login_note',$login_note);
}
}

View File

@ -7,7 +7,6 @@ use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use App\Models\User;
class RegisterController extends Controller
@ -30,7 +29,7 @@ class RegisterController extends Controller
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
protected $redirectTo = '/';
/**
* Create a new controller instance.

View File

@ -2,10 +2,10 @@
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\ResetsPasswords;
use App\Http\Controllers\Controller;
class ResetPasswordController extends Controller
{
/*
@ -26,15 +26,5 @@ class ResetPasswordController extends Controller
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
protected $redirectTo = '/';
}

View File

@ -2,10 +2,10 @@
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\VerifiesEmails;
use App\Http\Controllers\Controller;
class VerificationController extends Controller
{
/*
@ -26,7 +26,7 @@ class VerificationController extends Controller
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
protected $redirectTo = '/';
/**
* Create a new controller instance.

View File

@ -2,12 +2,10 @@
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Validation\ValidatesRequests;
class Controller extends BaseController
abstract class Controller extends \Illuminate\Routing\Controller
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
use AuthorizesRequests,ValidatesRequests;
}

View File

@ -5,7 +5,7 @@
@endsection
@section('content')
@includeWhen(session()->has('success'),'widgets.success-row',['msg'=>session()->get('success')])
@includeWhen(session()->has('status'),'widgets.success-row',['msg'=>session()->pull('status')])
<form class="needs-validation" method="post" action="{{ route('password.email') }}" novalidate>
@csrf

View File

@ -5,7 +5,7 @@
@endsection
@section('content')
@includeWhen(session()->has('status') || true,'widgets.success-row',['msg'=>session()->get('status')])
@includeWhen(session()->has('status'),'widgets.success-row',['msg'=>session()->pull('status')])
<form class="needs-validation" method="post" action="{{ route('password.update') }}" novalidate>
@csrf