diff --git a/exec/handlers/login.php b/exec/handlers/login.php index 6df9672..deda10f 100644 --- a/exec/handlers/login.php +++ b/exec/handlers/login.php @@ -10,9 +10,6 @@ return static function (): void { if (!$settings->defaultEnable()) { Http::errorPage('Plugin nie jest włączony dla tego serwera.', 403); } - if ($settings->method() !== 'login_url') { - Http::errorPage('Metoda logowania nie jest obsługiwana.', 500); - } $ctx = DirectAdminContext::fromServer($_SERVER, $settings); $auditBase = [ diff --git a/exec/lib/Settings.php b/exec/lib/Settings.php index 0e86729..e520db9 100644 --- a/exec/lib/Settings.php +++ b/exec/lib/Settings.php @@ -57,7 +57,6 @@ final class Settings { return [ 'DEFAULT_ENABLE' => 'true', - 'MAIL_LOGIN_METHOD' => 'login_url', 'MAIL_LOGIN_TARGET_NAME' => 'mx1', 'MAIL_LOGIN_TARGET_BASE_URL' => 'https://mx1.mojserwer.pl:2222', 'MAIL_LOGIN_REDIRECT_URL' => '/', @@ -110,11 +109,6 @@ final class Settings return in_array(strtolower($this->getString('DEFAULT_ENABLE', 'true')), ['1', 'true', 'yes', 'on'], true); } - public function method(): string - { - return $this->getString('MAIL_LOGIN_METHOD', 'login_url'); - } - public function redirectUrl(): string { return $this->getString('MAIL_LOGIN_REDIRECT_URL', '/'); @@ -258,9 +252,6 @@ final class Settings if (!in_array(strtolower($this->getString('DEFAULT_ENABLE', 'true')), ['0', '1', 'true', 'false', 'yes', 'no', 'on', 'off'], true)) { throw new InvalidArgumentException('DEFAULT_ENABLE must be a boolean value'); } - if ($this->method() !== 'login_url') { - throw new InvalidArgumentException('MAIL_LOGIN_METHOD must be login_url'); - } if (!in_array($this->clientIpMode(), ['direct', 'trusted_proxy'], true)) { throw new InvalidArgumentException('MAIL_LOGIN_CLIENT_IP_MODE must be direct or trusted_proxy'); } diff --git a/images/user_icon.svg b/images/user_icon.svg index 1fcbca7..66edd51 100644 --- a/images/user_icon.svg +++ b/images/user_icon.svg @@ -7,8 +7,8 @@ - - - - + + + + diff --git a/plugin-settings.conf b/plugin-settings.conf index 26e85a0..f98241c 100644 --- a/plugin-settings.conf +++ b/plugin-settings.conf @@ -5,9 +5,6 @@ # Czy plugin jest domyślnie dostępny dla wszystkich użytkowników. DEFAULT_ENABLE=true -# Metoda produkcyjna. Wersja 1 używa jednorazowego DirectAdmin login URL generowanego na MX. -MAIL_LOGIN_METHOD=login_url - # Login URL jest tworzony wyłącznie przez direct SSH command: # serwer źródłowy łączy się po SSH do MX i uruchamia bezpośrednio /usr/bin/da login-url. diff --git a/plugin.conf b/plugin.conf index a516032..547bffe 100644 --- a/plugin.conf +++ b/plugin.conf @@ -2,7 +2,7 @@ name=MX-Autologin id=mxautologin type=user author=HITME.PL -version=1.1.3 +version=1.1.4 active=no installed=no user_run_as=root diff --git a/tests/package_contents_test.php b/tests/package_contents_test.php index de47970..f3d1168 100644 --- a/tests/package_contents_test.php +++ b/tests/package_contents_test.php @@ -8,7 +8,7 @@ test('plugin metadata and packaging docs match project rules', function (): void assert_contains('name=MX-Autologin', $conf); assert_contains('id=mxautologin', $conf); assert_contains('type=user', $conf); - assert_contains('version=1.1.3', $conf); + assert_contains('version=1.1.4', $conf); assert_contains('user_run_as=root', $conf); assert_contains('/Users/marek/GPT/ChatGPT/da_plugins/mail-login/src', $packing); assert_contains('/Users/marek/GPT/ChatGPT/da_plugins/mail-login/archives/X.Y.Z/mxautologin.tar.gz', $packing); @@ -86,6 +86,7 @@ test('plugin icon follows directadmin login screen palette', function (): void { assert_contains('#2ec4b6', $icon); assert_contains('#2f95c8', $icon); assert_contains('#ff8a00', $icon); + assert_contains('fill="#ff8a00"', $icon); assert_contains('#ffffff', $icon); assert_not_contains('#14532d', $icon); }); diff --git a/tests/settings_test.php b/tests/settings_test.php index 881ef1e..cc90163 100644 --- a/tests/settings_test.php +++ b/tests/settings_test.php @@ -11,7 +11,6 @@ test('settings expose secure defaults from plugin-settings.conf', function (): v assert_true($settings->ipMask()); assert_same('MASKED', $settings->auditClientIp('198.51.100.10')); assert_true($settings->defaultEnable()); - assert_same('login_url', $settings->method()); assert_same('root', $settings->sshUser()); assert_same('https://mx1.mojserwer.pl:2222', $settings->targetBaseUrl()); }); @@ -77,14 +76,15 @@ test('settings do not expose mx helper mode', function (): void { assert_not_contains('MX_LOGIN_MODE', $config); }); -test('settings reject disabled plugin and unsupported methods through access guard', function (): void { - try { - Settings::fromArray(['MAIL_LOGIN_METHOD' => 'password']); - throw new RuntimeException('Expected unsupported method to fail'); - } catch (InvalidArgumentException $e) { - assert_contains('MAIL_LOGIN_METHOD', $e->getMessage()); - } +test('settings do not expose deprecated mail login method switch', function (): void { + $defaults = Settings::defaults(); + $config = file_get_contents(PLUGIN_ROOT . '/plugin-settings.conf') ?: ''; + assert_false(array_key_exists('MAIL_LOGIN_METHOD', $defaults)); + assert_not_contains('MAIL_LOGIN_METHOD', $config); +}); + +test('settings expose disabled plugin flag through access guard', function (): void { $settings = Settings::fromArray(['DEFAULT_ENABLE' => 'false']); assert_false($settings->defaultEnable()); });