Skip to content

Commit

Permalink
Add method DI
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperDJ committed Nov 14, 2024
1 parent 947e0e4 commit d8255c5
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/Http/Controllers/AuthenticatedSessionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,15 @@ protected function loginPipeline(LoginRequest $request)
* Destroy an authenticated session.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Contracts\Auth\StatefulGuard|null $guard
* @return \Laravel\Fortify\Contracts\LogoutResponse
*/
public function destroy(Request $request): LogoutResponse
public function destroy(Request $request, StatefulGuard|null $guard = null): LogoutResponse
{
if ($guard) {
$this->guard = $guard;
}

$this->guard->logout();

if ($request->hasSession()) {
Expand Down
7 changes: 6 additions & 1 deletion src/Http/Controllers/ConfirmablePasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,15 @@ public function show(Request $request)
* Confirm the user's password.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Contracts\Auth\StatefulGuard|null $guard
* @return \Illuminate\Contracts\Support\Responsable
*/
public function store(Request $request)
public function store(Request $request, StatefulGuard|null $guard = null)
{
if ($guard) {
$this->guard = $guard;
}

$confirmed = app(ConfirmPassword::class)(
$this->guard, $request->user(), $request->input('password')
);
Expand Down
7 changes: 6 additions & 1 deletion src/Http/Controllers/NewPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,15 @@ public function create(Request $request): ResetPasswordViewResponse
* Reset the user's password.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Contracts\Auth\StatefulGuard|null $guard
* @return \Illuminate\Contracts\Support\Responsable
*/
public function store(Request $request): Responsable
public function store(Request $request, StatefulGuard|null $guard = null): Responsable
{
if ($guard) {
$this->guard = $guard;
}

$request->validate([
'token' => 'required',
Fortify::email() => 'required|email',
Expand Down
7 changes: 6 additions & 1 deletion src/Http/Controllers/RegisteredUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,16 @@ public function create(Request $request): RegisterViewResponse
*
* @param \Illuminate\Http\Request $request
* @param \Laravel\Fortify\Contracts\CreatesNewUsers $creator
* @param \Illuminate\Contracts\Auth\StatefulGuard|null $guard
* @return \Laravel\Fortify\Contracts\RegisterResponse
*/
public function store(Request $request,
CreatesNewUsers $creator): RegisterResponse
CreatesNewUsers $creator, StatefulGuard|null $guard = null): RegisterResponse
{
if ($guard) {
$this->guard = $guard;
}

if (config('fortify.lowercase_usernames')) {
$request->merge([
Fortify::username() => Str::lower($request->{Fortify::username()}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,15 @@ public function create(TwoFactorLoginRequest $request): TwoFactorChallengeViewRe
* Attempt to authenticate a new session using the two factor authentication code.
*
* @param \Laravel\Fortify\Http\Requests\TwoFactorLoginRequest $request
* @param \Illuminate\Contracts\Auth\StatefulGuard|null $guard
* @return mixed
*/
public function store(TwoFactorLoginRequest $request)
public function store(TwoFactorLoginRequest $request, StatefulGuard|null $guard = null)
{
if ($guard) {
$this->guard = $guard;
}

$user = $request->challengedUser();

if ($code = $request->validRecoveryCode()) {
Expand Down

0 comments on commit d8255c5

Please sign in to comment.