summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-03-26 11:21:47 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2018-03-26 11:31:02 +0200
commitb52c935c09f4cd4535825a16a8867eb1905864d2 (patch)
treeb89e0ac8146caec9a6d085ac6d3b6462fd81a088
parent24b12385d0e5f7483a64f2abf543f9c4e09a6eaa (diff)
downloadnextcloud-server-b52c935c09f4cd4535825a16a8867eb1905864d2.tar.gz
nextcloud-server-b52c935c09f4cd4535825a16a8867eb1905864d2.zip
Make 2FA backupcodes strict
* and follow the interface again Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
-rw-r--r--apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php18
1 files changed, 10 insertions, 8 deletions
diff --git a/apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php b/apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php
index f5b01649bbb..03d1ee0d405 100644
--- a/apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php
+++ b/apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php
@@ -1,4 +1,5 @@
<?php
+declare(strict_types=1);
/**
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
@@ -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;
@@ -61,7 +62,7 @@ class BackupCodesProvider implements IProvider {
*
* @return string
*/
- public function getId() {
+ public function getId(): string {
return 'backup_codes';
}
@@ -70,7 +71,7 @@ class BackupCodesProvider implements IProvider {
*
* @return string
*/
- public function getDisplayName() {
+ public function getDisplayName(): string {
return $this->l10n->t('Backup code');
}
@@ -79,7 +80,7 @@ class BackupCodesProvider implements IProvider {
*
* @return string
*/
- public function getDescription() {
+ public function getDescription(): string {
return $this->l10n->t('Use backup code');
}
@@ -89,7 +90,7 @@ class BackupCodesProvider implements IProvider {
* @param IUser $user
* @return Template
*/
- public function getTemplate(IUser $user) {
+ public function getTemplate(IUser $user): Template {
return new Template('twofactor_backupcodes', 'challenge');
}
@@ -98,8 +99,9 @@ class BackupCodesProvider implements IProvider {
*
* @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);
}
@@ -109,7 +111,7 @@ class BackupCodesProvider implements IProvider {
* @param IUser $user
* @return boolean
*/
- public function isTwoFactorAuthEnabledForUser(IUser $user) {
+ public function isTwoFactorAuthEnabledForUser(IUser $user): bool {
return $this->storage->hasBackupCodes($user);
}
@@ -124,7 +126,7 @@ class BackupCodesProvider implements IProvider {
* @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;
});