mirror of
https://github.com/chylex/Lightning-Tracker.git
synced 2025-04-10 02:15:43 +02:00
Fix wrong login return path when request's and navigation's base paths mismatch
This commit is contained in:
parent
5df6c75c43
commit
021cfc9538
src/Pages
Controllers/Mixed
Models
@ -18,8 +18,8 @@ use function Pages\Actions\redirect;
|
||||
use function Pages\Actions\view;
|
||||
|
||||
class LoginController extends AbstractHandlerController{
|
||||
public static function getReturnQuery(Request $req): string{
|
||||
$base_path_components = [BASE_PATH, $req->getBasePath()->raw()];
|
||||
public static function getReturnQuery(Request $req, bool $force_full_path = false): string{
|
||||
$base_path_components = [BASE_PATH, $force_full_path ? '' : $req->getBasePath()->raw()];
|
||||
$base_path = implode('/', array_filter(array_map(fn($v): string => ltrim($v, '/'), $base_path_components), fn($v): bool => !empty($v)));
|
||||
$base_path_len = mb_strlen($base_path);
|
||||
|
||||
|
@ -6,7 +6,6 @@ namespace Pages\Models;
|
||||
use LogicException;
|
||||
use Pages\Components\Navigation\NavigationComponent;
|
||||
use Pages\Components\Text;
|
||||
use Pages\Controllers\Mixed\LoginController;
|
||||
use Pages\IModel;
|
||||
use Routing\Request;
|
||||
use Session\PermissionManager;
|
||||
@ -24,6 +23,7 @@ abstract class AbstractPageModel implements IModel{
|
||||
|
||||
protected abstract function createNavigation(): NavigationComponent;
|
||||
protected abstract function setupNavigation(NavigationComponent $nav, PermissionManager $perms): void;
|
||||
protected abstract function getLoginReturnQuery(): string;
|
||||
|
||||
public function load(): IModel{
|
||||
$this->is_loaded = true;
|
||||
@ -38,7 +38,7 @@ abstract class AbstractPageModel implements IModel{
|
||||
$this->nav->addRight(Text::withIcon($logon_user->getName(), 'user'), '/account');
|
||||
}
|
||||
else{
|
||||
$this->nav->addRight(Text::withIcon('Login', 'enter'), '/login'.LoginController::getReturnQuery($this->getReq()));
|
||||
$this->nav->addRight(Text::withIcon('Login', 'enter'), '/login'.$this->getLoginReturnQuery());
|
||||
|
||||
if (SYS_ENABLE_REGISTRATION){
|
||||
$this->nav->addRight(Text::withIcon('Register', 'user'), '/register');
|
||||
|
@ -5,6 +5,7 @@ namespace Pages\Models;
|
||||
|
||||
use Pages\Components\Navigation\NavigationComponent;
|
||||
use Pages\Components\Text;
|
||||
use Pages\Controllers\Mixed\LoginController;
|
||||
use Pages\Models\Root\SettingsModel;
|
||||
use Routing\Request;
|
||||
use Routing\UrlString;
|
||||
@ -35,6 +36,10 @@ class BasicRootPageModel extends AbstractPageModel{
|
||||
|
||||
$nav->addLeft(Text::withIcon('About', 'info'), '/about');
|
||||
}
|
||||
|
||||
protected function getLoginReturnQuery(): string{
|
||||
return LoginController::getReturnQuery($this->getReq(), true);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -14,6 +14,7 @@ use Pages\Components\Html;
|
||||
use Pages\Components\Navigation\NavigationComponent;
|
||||
use Pages\Components\ProgressBarComponent;
|
||||
use Pages\Components\Text;
|
||||
use Pages\Controllers\Mixed\LoginController;
|
||||
use Pages\IViewable;
|
||||
use Routing\Request;
|
||||
use Session\PermissionManager;
|
||||
@ -51,6 +52,10 @@ class BasicTrackerPageModel extends AbstractPageModel{
|
||||
}
|
||||
}
|
||||
|
||||
protected function getLoginReturnQuery(): string{
|
||||
return LoginController::getReturnQuery($this->getReq());
|
||||
}
|
||||
|
||||
public function getTracker(): TrackerInfo{
|
||||
return $this->tracker;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user