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
18 changes: 10 additions & 8 deletions apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);

/**
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
Expand Down Expand Up @@ -49,7 +50,7 @@ class BackupCodesProvider implements IProvider {
* @param IL10N $l10n
* @param AppManager $appManager
*/
public function __construct($appName, BackupCodeStorage $storage, IL10N $l10n, AppManager $appManager) {
public function __construct(string $appName, BackupCodeStorage $storage, IL10N $l10n, AppManager $appManager) {
$this->appName = $appName;
$this->l10n = $l10n;
$this->storage = $storage;
Expand All @@ -61,7 +62,7 @@ public function __construct($appName, BackupCodeStorage $storage, IL10N $l10n, A
*
* @return string
*/
public function getId() {
public function getId(): string {
return 'backup_codes';
}

Expand All @@ -70,7 +71,7 @@ public function getId() {
*
* @return string
*/
public function getDisplayName() {
public function getDisplayName(): string {
return $this->l10n->t('Backup code');
}

Expand All @@ -79,7 +80,7 @@ public function getDisplayName() {
*
* @return string
*/
public function getDescription() {
public function getDescription(): string {
return $this->l10n->t('Use backup code');
}

Expand All @@ -89,7 +90,7 @@ public function getDescription() {
* @param IUser $user
* @return Template
*/
public function getTemplate(IUser $user) {
public function getTemplate(IUser $user): Template {
return new Template('twofactor_backupcodes', 'challenge');
}

Expand All @@ -98,8 +99,9 @@ public function getTemplate(IUser $user) {
*
* @param IUser $user
* @param string $challenge
* @return bool
*/
public function verifyChallenge(IUser $user, $challenge) {
public function verifyChallenge(IUser $user, string $challenge): bool {
return $this->storage->validateCode($user, $challenge);
}

Expand All @@ -109,7 +111,7 @@ public function verifyChallenge(IUser $user, $challenge) {
* @param IUser $user
* @return boolean
*/
public function isTwoFactorAuthEnabledForUser(IUser $user) {
public function isTwoFactorAuthEnabledForUser(IUser $user): bool {
return $this->storage->hasBackupCodes($user);
}

Expand All @@ -124,7 +126,7 @@ public function isTwoFactorAuthEnabledForUser(IUser $user) {
* @param IUser $user
* @return boolean
*/
public function isActive(IUser $user) {
public function isActive(IUser $user): bool {
$appIds = array_filter($this->appManager->getEnabledAppsForUser($user), function($appId) {
return $appId !== $this->appName;
});
Expand Down
16 changes: 9 additions & 7 deletions lib/public/Authentication/TwoFactorAuth/IProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
Expand Down Expand Up @@ -43,7 +44,7 @@ interface IProvider {
*
* @return string
*/
public function getId();
public function getId(): string;

/**
* Get the display name for selecting the 2FA provider
Expand All @@ -54,7 +55,7 @@ public function getId();
*
* @return string
*/
public function getDisplayName();
public function getDisplayName(): string;

/**
* Get the description for selecting the 2FA provider
Expand All @@ -65,7 +66,7 @@ public function getDisplayName();
*
* @return string
*/
public function getDescription();
public function getDescription(): string;

/**
* Get the template for rending the 2FA provider view
Expand All @@ -75,7 +76,7 @@ public function getDescription();
* @param IUser $user
* @return Template
*/
public function getTemplate(IUser $user);
public function getTemplate(IUser $user): Template;

/**
* Verify the given challenge
Expand All @@ -84,16 +85,17 @@ public function getTemplate(IUser $user);
*
* @param IUser $user
* @param string $challenge
* @return bool
*/
public function verifyChallenge(IUser $user, $challenge);
public function verifyChallenge(IUser $user, string $challenge): bool;

/**
* Decides whether 2FA is enabled for the given user
*
* @since 9.1.0
*
* @param IUser $user
* @return boolean
* @return bool
*/
public function isTwoFactorAuthEnabledForUser(IUser $user);
public function isTwoFactorAuthEnabledForUser(IUser $user): bool;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
*
*
Expand Down Expand Up @@ -35,5 +36,5 @@ interface IProvidesCustomCSP {
*
* @since 13.0.0
*/
public function getCSP();
public function getCSP(): ContentSecurityPolicy;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud GmbH.
*
Expand Down