Plain-PHP fleet platform with id.andmore.pt SSO. Wires shared/platform-tools as a submodule (platform_update, backups, git/migration tools) like the other platforms. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
36 lines
1.3 KiB
PHP
36 lines
1.3 KiB
PHP
<?php
|
|
// SSO-only platform: there is no local registration form. Accounts live on
|
|
// id.andmore.pt and are mirrored locally by sso_resolve_session() the first
|
|
// time the user lands on this platform. This file exists only so old
|
|
// /views/auth/register.php links bounce through to the central registration.
|
|
|
|
require __DIR__ . '/../../config/db.php';
|
|
require_once __DIR__ . '/../../config/functions.php';
|
|
|
|
// Already authenticated? Skip the bounce and land on the right dashboard.
|
|
if (empty($_SESSION['user_id']) && identity_is_federated()) {
|
|
sso_resolve_session($pdo);
|
|
}
|
|
|
|
$next = $_GET['next'] ?? '';
|
|
$session_id = (int) ($_GET['session_id'] ?? 0);
|
|
$claim_intent = ($next === 'session' && $session_id > 0);
|
|
|
|
$dashboard_for = function (string $role) use ($claim_intent, $session_id): string {
|
|
if ($claim_intent && $role === 'client') {
|
|
return 'views/user/dashboard.php?focus_session=' . $session_id;
|
|
}
|
|
return post_login_destination($role);
|
|
};
|
|
|
|
if (!empty($_SESSION['user_id'])) {
|
|
header('Location: ' . base_url($dashboard_for($_SESSION['user']['role'] ?? '')));
|
|
exit;
|
|
}
|
|
|
|
$return_to = base_url('views/auth/login.php'
|
|
. ($claim_intent ? '?next=session&session_id=' . $session_id : ''));
|
|
|
|
header('Location: ' . ANDMORE_ID_URL . 'auth/register.php?return_to=' . urlencode($return_to));
|
|
exit;
|