Skip to content

Commit

Permalink
Fix 2fa icons in dark theme, fix #13643
Browse files Browse the repository at this point in the history
Signed-off-by: Greta Doci <[email protected]>
  • Loading branch information
GretaD committed May 22, 2019
1 parent 74ad4cc commit cba56d7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
8 changes: 8 additions & 0 deletions lib/private/Settings/Personal/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
use OCP\IUserSession;
use OCP\Session\Exceptions\SessionNotAvailableException;
use OCP\Settings\ISettings;
use OCP\IConfig;

class Security implements ISettings {

Expand Down Expand Up @@ -69,13 +70,18 @@ class Security implements ISettings {
* @var string|null
*/
private $uid;
/**
*@var IConfig
*/
private $config;

public function __construct(IUserManager $userManager,
TwoFactorManager $providerManager,
IAuthTokenProvider $tokenProvider,
ProviderLoader $providerLoader,
IUserSession $userSession,
ISession $session,
IConfig $config,
IInitialStateService $initialStateService,
?string $UserId) {
$this->userManager = $userManager;
Expand All @@ -86,6 +92,7 @@ public function __construct(IUserManager $userManager,
$this->session = $session;
$this->initialStateService = $initialStateService;
$this->uid = $UserId;
$this->config = $config;
}

/**
Expand All @@ -108,6 +115,7 @@ public function getForm() {
return new TemplateResponse('settings', 'settings/personal/security', [
'passwordChangeSupported' => $passwordChangeSupported,
'twoFactorProviderData' => $this->getTwoFactorProviderData(),
'themedark' => $this->config->getUserValue($this->uid, 'accessibility', 'theme', false)
]);
}

Expand Down
20 changes: 17 additions & 3 deletions settings/templates/settings/personal/security.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,29 @@
href="<?php p(link_to_docs('user-2fa')); ?>"></a>
<p class="settings-hint"><?php p($l->t('Use a second factor besides your password to increase security for your account.'));?></p>
<ul>
<?php foreach ($_['twoFactorProviderData']['providers'] as $data) { ?>
<?php foreach ($_['twoFactorProviderData']['providers'] as $data) { ?>
<li>
<?php

/** @var \OCP\Authentication\TwoFactorAuth\IProvidesPersonalSettings $provider */
$provider = $data['provider'];
//Handle 2FA provider icons and theme
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 {
$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 */
$settings = $data['settings'];
Expand Down

0 comments on commit cba56d7

Please sign in to comment.