Skip to content
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
15 changes: 12 additions & 3 deletions login.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
$centralLogin = \App\Auth\FabricaClient::enabled();
$registrationMode = defined('REGISTRATION_MODE') ? REGISTRATION_MODE : 'open';
$error = \App\Session\SessionManager::pullRegistrationError();
// Discord and Sync forbid framing: in the ef_bridge tablet their button only led to a black frame.
$inGame = \App\Http\FiveMSupport::isCitizenFx();

// Handle code submission
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['registration_code'])) {
Expand Down Expand Up @@ -76,7 +78,11 @@
<?php // Die Wortmarke ist der Kopf der Schale, alles bis zu den Aktionen liegt in der Mulde, der Fuß steht auf dem Rand. ?>
<div class="twplus-login__well">
<h1 id="loginHeader" class="twplus-login__title">Willkommen zurück</h1>
<p class="twplus-login__lead">Melde dich an, um in <?= htmlspecialchars((string) SERVER_CITY) ?> weiterzuarbeiten.</p>
<?php if ($inGame): ?>
<p class="twplus-login__lead">Im Spiel meldet dich das Tablet selbst an. Klappt das nicht, schließe das Tablet und öffne es erneut.</p>
<?php else: ?>
<p class="twplus-login__lead">Melde dich an, um in <?= htmlspecialchars((string) SERVER_CITY) ?> weiterzuarbeiten.</p>
<?php endif; ?>

<?php
if ($error) {
Expand All @@ -86,11 +92,12 @@
}

// Normal login view
if ($registrationMode === 'closed' && !$error) {
// No registration in the game: the code form ends at Discord or Sync as well.
if (!$inGame && $registrationMode === 'closed' && !$error) {
echo '<div class="ignis-alert ignis-alert--warn mb-4" role="alert">';
echo '<i class="fa-solid fa-lock ignis-alert__icon"></i><div class="ignis-alert__body">Registrierung für neue Benutzer ist derzeit geschlossen.</div>';
echo '</div>';
} elseif ($registrationMode === 'code') {
} elseif (!$inGame && $registrationMode === 'code') {
if (!$error) {
echo '<div class="ignis-alert ignis-alert--info mb-4" role="alert">';
echo '<i class="fa-solid fa-ticket ignis-alert__icon"></i><div class="ignis-alert__body"><strong>Einladung erforderlich</strong><br>Neue Benutzer benötigen einen Registrierungscode.</div>';
Expand All @@ -110,9 +117,11 @@
}
?>

<?php if (!$inGame): ?>
<div class="twplus-login__actions">
<a href="<?= BASE_PATH ?><?= $centralLogin ? 'auth/fabrica' : 'auth/discord' ?>" class="ignis-btn ignis-btn--primary ignis-btn--lg block w-full"><?php if ($centralLogin): ?><span aria-hidden="true" style="display:inline-flex;align-self:center;flex-shrink:0;"><?= str_replace('<svg ', '<svg width="28" height="16" ', (string) file_get_contents(__DIR__ . '/assets/img/ef-mark.svg')) ?></span><?php else: ?><i class="fa-brands fa-discord" aria-hidden="true"></i><?php endif; ?> Mit <?= $centralLogin ? 'Sync' : 'Discord' ?> anmelden</a>
</div>
<?php endif; ?>
</div>

<?php
Expand Down
13 changes: 13 additions & 0 deletions tests/Feature/TabletLoginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,19 @@ public function die_login_seite_meldet_dem_tablet_die_fehlende_sitzung(): void
$this->assertStringContainsString('ef_tablet_signed_out', $this->get('/login')->body);
}

#[Test]
public function im_spiel_zeigt_die_login_seite_keinen_discord_oder_sync_knopf(): void
{
$this->assertStringContainsString('auth/discord', $this->get('/login')->body);

// Discord and Sync refuse to be framed, the tablet would turn black.
$game = $this->get('/login', ['headers' => ['User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.134 CitizenFX/1.0.0.12345 Safari/537.36']])->body;
$this->assertStringNotContainsString('auth/discord', $game);
$this->assertStringNotContainsString('auth/fabrica', $game);
$this->assertStringContainsString('schließe das Tablet und öffne es erneut', $game);
$this->assertStringContainsString('ef_tablet_signed_out', $game);
}

#[Test]
public function ein_abgelaufener_oder_fremder_token_meldet_nicht_an(): void
{
Expand Down
Loading