Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Redirecting to wrong panel after challenge #3

Merged
merged 6 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Http/Livewire/Auth/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ protected function getFormSchema(): array

public function loginWithFortify()
{
session()->put('panel', Filament::getCurrentPanel()->getId());

try {
$this->rateLimit(5);
} catch (TooManyRequestsException $exception) {
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Livewire/Auth/PasswordReset.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PasswordReset extends Page implements HasForms
public function mount(): void
{
if (Filament::auth()->check()) {
redirect()->intended(Filament::getUrl());
redirect()->intended(Filament::getCurrentPanel()->getUrl());
}

if (session('status')) {
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Livewire/Auth/RequestPasswordReset.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class RequestPasswordReset extends Page implements HasForms
public function mount(): void
{
if (Filament::auth()->check()) {
redirect()->intended(Filament::getUrl());
redirect()->intended(Filament::getCurrentPanel()->getUrl());
}

if (session('status')) {
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Responses/LoginResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public function toResponse($request)
{
return $request->wantsJson()
? response()->json(['two_factor' => false])
: redirect()->intended(Filament::getUrl());
: redirect()->intended(Filament::getCurrentPanel()->getUrl());
}
}
2 changes: 1 addition & 1 deletion src/Http/Responses/TwoFactorChallengeViewResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ class TwoFactorChallengeViewResponse implements LoginResponseContract
*/
public function toResponse($request)
{
return redirect()->intended(Filament::getUrl());
return redirect()->intended(Filament::getCurrentPanel()->getUrl());
}
}
6 changes: 5 additions & 1 deletion src/Http/Responses/TwoFactorLoginResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class TwoFactorLoginResponse implements LoginResponseContract
*/
public function toResponse($request)
{
return redirect()->intended(Filament::getUrl());
$panel = Filament::getPanel(session()->get('panel'));

session()->forget('panel');

return redirect()->intended($panel->getUrl());
}
}