Skip to content
Snippets Groups Projects
Commit 536b4106 authored by Greta Doci's avatar Greta Doci
Browse files

Fix 2fa icons in dark theme, fix #13643


Signed-off-by: default avatarGreta Doci <gretadoci@gmail.com>
parent 74ad4cce
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,7 @@ use OCP\IUserManager; ...@@ -42,6 +42,7 @@ use OCP\IUserManager;
use OCP\IUserSession; use OCP\IUserSession;
use OCP\Session\Exceptions\SessionNotAvailableException; use OCP\Session\Exceptions\SessionNotAvailableException;
use OCP\Settings\ISettings; use OCP\Settings\ISettings;
use OCP\IConfig;
class Security implements ISettings { class Security implements ISettings {
...@@ -69,6 +70,10 @@ class Security implements ISettings { ...@@ -69,6 +70,10 @@ class Security implements ISettings {
* @var string|null * @var string|null
*/ */
private $uid; private $uid;
/**
*@var IConfig
*/
private $config;
public function __construct(IUserManager $userManager, public function __construct(IUserManager $userManager,
TwoFactorManager $providerManager, TwoFactorManager $providerManager,
...@@ -76,6 +81,7 @@ class Security implements ISettings { ...@@ -76,6 +81,7 @@ class Security implements ISettings {
ProviderLoader $providerLoader, ProviderLoader $providerLoader,
IUserSession $userSession, IUserSession $userSession,
ISession $session, ISession $session,
IConfig $config,
IInitialStateService $initialStateService, IInitialStateService $initialStateService,
?string $UserId) { ?string $UserId) {
$this->userManager = $userManager; $this->userManager = $userManager;
...@@ -86,6 +92,7 @@ class Security implements ISettings { ...@@ -86,6 +92,7 @@ class Security implements ISettings {
$this->session = $session; $this->session = $session;
$this->initialStateService = $initialStateService; $this->initialStateService = $initialStateService;
$this->uid = $UserId; $this->uid = $UserId;
$this->config = $config;
} }
/** /**
...@@ -108,6 +115,7 @@ class Security implements ISettings { ...@@ -108,6 +115,7 @@ class Security implements ISettings {
return new TemplateResponse('settings', 'settings/personal/security', [ return new TemplateResponse('settings', 'settings/personal/security', [
'passwordChangeSupported' => $passwordChangeSupported, 'passwordChangeSupported' => $passwordChangeSupported,
'twoFactorProviderData' => $this->getTwoFactorProviderData(), 'twoFactorProviderData' => $this->getTwoFactorProviderData(),
'themedark' => $this->config->getUserValue($this->uid, 'accessibility', 'theme', false)
]); ]);
} }
......
...@@ -69,12 +69,26 @@ if($_['passwordChangeSupported']) { ...@@ -69,12 +69,26 @@ if($_['passwordChangeSupported']) {
<?php foreach ($_['twoFactorProviderData']['providers'] as $data) { ?> <?php foreach ($_['twoFactorProviderData']['providers'] as $data) { ?>
<li> <li>
<?php <?php
/** @var \OCP\Authentication\TwoFactorAuth\IProvidesPersonalSettings $provider */ /** @var \OCP\Authentication\TwoFactorAuth\IProvidesPersonalSettings $provider */
$provider = $data['provider']; $provider = $data['provider'];
//Handle 2FA provider icons and theme
if ($provider instanceof \OCP\Authentication\TwoFactorAuth\IProvidesIcons) { if ($provider instanceof \OCP\Authentication\TwoFactorAuth\IProvidesIcons) {
$icon = $provider->getDarkIcon(); if ($_['themedark']) {
$icon = $provider->getLightIcon();
}
else {
$icon = $provider->getDarkIcon();
}
//fallback icon if the 2factor provider doesn't provide an icon.
} else { } else {
$icon = image_path('core', 'actions/password.svg'); if ($_['themedark']) {
$icon = image_path('core', 'actions/password-white.svg');
}
else {
$icon = image_path('core', 'actions/password.svg');
}
} }
/** @var \OCP\Authentication\TwoFactorAuth\IPersonalProviderSettings $settings */ /** @var \OCP\Authentication\TwoFactorAuth\IPersonalProviderSettings $settings */
$settings = $data['settings']; $settings = $data['settings'];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment