Completed
Pull Request — master (#3829)
by Maxence
12:57
created
apps/theming/lib/Settings/Admin.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -31,72 +31,72 @@
 block discarded – undo
31 31
 use OCP\Settings\ISettings;
32 32
 
33 33
 class Admin implements ISettings {
34
-	/** @var IConfig */
35
-	private $config;
36
-	/** @var IL10N */
37
-	private $l;
38
-	/** @var ThemingDefaults */
39
-	private $themingDefaults;
40
-	/** @var IURLGenerator */
41
-	private $urlGenerator;
34
+    /** @var IConfig */
35
+    private $config;
36
+    /** @var IL10N */
37
+    private $l;
38
+    /** @var ThemingDefaults */
39
+    private $themingDefaults;
40
+    /** @var IURLGenerator */
41
+    private $urlGenerator;
42 42
 
43
-	public function __construct(IConfig $config,
44
-								IL10N $l,
45
-								ThemingDefaults $themingDefaults,
46
-								IURLGenerator $urlGenerator) {
47
-		$this->config = $config;
48
-		$this->l = $l;
49
-		$this->themingDefaults = $themingDefaults;
50
-		$this->urlGenerator = $urlGenerator;
51
-	}
43
+    public function __construct(IConfig $config,
44
+                                IL10N $l,
45
+                                ThemingDefaults $themingDefaults,
46
+                                IURLGenerator $urlGenerator) {
47
+        $this->config = $config;
48
+        $this->l = $l;
49
+        $this->themingDefaults = $themingDefaults;
50
+        $this->urlGenerator = $urlGenerator;
51
+    }
52 52
 
53
-	/**
54
-	 * @return TemplateResponse
55
-	 */
56
-	public function getForm() {
57
-		$path = $this->urlGenerator->linkToRoute('theming.Theming.updateLogo');
53
+    /**
54
+     * @return TemplateResponse
55
+     */
56
+    public function getForm() {
57
+        $path = $this->urlGenerator->linkToRoute('theming.Theming.updateLogo');
58 58
 
59
-		$themable = true;
60
-		$errorMessage = '';
61
-		$theme = $this->config->getSystemValue('theme', '');
62
-		if ($theme !== '') {
63
-			$themable = false;
64
-			$errorMessage = $this->l->t('You are already using a custom theme');
65
-		}
59
+        $themable = true;
60
+        $errorMessage = '';
61
+        $theme = $this->config->getSystemValue('theme', '');
62
+        if ($theme !== '') {
63
+            $themable = false;
64
+            $errorMessage = $this->l->t('You are already using a custom theme');
65
+        }
66 66
 
67
-		$parameters = [
68
-			'themable'        => $themable,
69
-			'errorMessage'    => $errorMessage,
70
-			'name'            => $this->themingDefaults->getEntity(),
71
-			'url'             => $this->themingDefaults->getBaseUrl(),
72
-			'slogan'          => $this->themingDefaults->getSlogan(),
73
-			'color'           => $this->themingDefaults->getMailHeaderColor(),
74
-			'logo'            => $this->themingDefaults->getLogo(),
75
-			'logoMime'        => $this->config->getAppValue('theming', 'logoMime', ''),
76
-			'background'      => $this->themingDefaults->getBackground(),
77
-			'backgroundMime'  => $this->config->getAppValue('theming', 'backgroundMime', ''),
78
-			'uploadLogoRoute' => $path,
79
-		];
67
+        $parameters = [
68
+            'themable'        => $themable,
69
+            'errorMessage'    => $errorMessage,
70
+            'name'            => $this->themingDefaults->getEntity(),
71
+            'url'             => $this->themingDefaults->getBaseUrl(),
72
+            'slogan'          => $this->themingDefaults->getSlogan(),
73
+            'color'           => $this->themingDefaults->getMailHeaderColor(),
74
+            'logo'            => $this->themingDefaults->getLogo(),
75
+            'logoMime'        => $this->config->getAppValue('theming', 'logoMime', ''),
76
+            'background'      => $this->themingDefaults->getBackground(),
77
+            'backgroundMime'  => $this->config->getAppValue('theming', 'backgroundMime', ''),
78
+            'uploadLogoRoute' => $path,
79
+        ];
80 80
 
81
-		return new TemplateResponse('theming', 'settings-admin', $parameters, '');
82
-	}
81
+        return new TemplateResponse('theming', 'settings-admin', $parameters, '');
82
+    }
83 83
 
84
-	/**
85
-	 * @return string the section ID, e.g. 'sharing'
86
-	 */
87
-	public function getSection() {
88
-		return 'theming';
89
-	}
84
+    /**
85
+     * @return string the section ID, e.g. 'sharing'
86
+     */
87
+    public function getSection() {
88
+        return 'theming';
89
+    }
90 90
 
91
-	/**
92
-	 * @return int whether the form should be rather on the top or bottom of
93
-	 * the admin section. The forms are arranged in ascending order of the
94
-	 * priority values. It is required to return a value between 0 and 100.
95
-	 *
96
-	 * E.g.: 70
97
-	 */
98
-	public function getPriority() {
99
-		return 5;
100
-	}
91
+    /**
92
+     * @return int whether the form should be rather on the top or bottom of
93
+     * the admin section. The forms are arranged in ascending order of the
94
+     * priority values. It is required to return a value between 0 and 100.
95
+     *
96
+     * E.g.: 70
97
+     */
98
+    public function getPriority() {
99
+        return 5;
100
+    }
101 101
 
102 102
 }
Please login to merge, or discard this patch.
apps/theming/appinfo/routes.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -25,58 +25,58 @@
 block discarded – undo
25 25
  */
26 26
 
27 27
 return ['routes' => [
28
-	[
29
-		'name' => 'Theming#updateStylesheet',
30
-		'url' => '/ajax/updateStylesheet',
31
-		'verb' => 'POST'
32
-	],
33
-	[
34
-		'name' => 'Theming#undo',
35
-		'url' => '/ajax/undoChanges',
36
-		'verb' => 'POST'
37
-	],
38
-	[
39
-		'name' => 'Theming#updateLogo',
40
-		'url' => '/ajax/updateLogo',
41
-		'verb' => 'POST'
42
-	],
43
-	[
44
-		'name' => 'Theming#getStylesheet',
45
-		'url' => '/styles',
46
-		'verb' => 'GET',
47
-	],
48
-	[
49
-		'name' => 'Theming#getLogo',
50
-		'url' => '/logo',
51
-		'verb' => 'GET',
52
-	],
53
-	[
54
-		'name' => 'Theming#getLoginBackground',
55
-		'url' => '/loginbackground',
56
-		'verb' => 'GET',
57
-	],
58
-	[
59
-		'name' => 'Theming#getJavascript',
60
-		'url' => '/js/theming',
61
-		'verb' => 'GET',
62
-	],
63
-	[
64
-		'name'	=> 'Icon#getFavicon',
65
-		'url' => '/favicon/{app}',
66
-		'verb' => 'GET',
67
-		'defaults' => array('app' => 'core'),
68
-	],
69
-	[
70
-		'name'	=> 'Icon#getTouchIcon',
71
-		'url' => '/icon/{app}',
72
-		'verb' => 'GET',
73
-		'defaults' => array('app' => 'core'),
74
-	],
75
-	[
76
-		'name'	=> 'Icon#getThemedIcon',
77
-		'url' => '/img/{app}/{image}',
78
-		'verb' => 'GET',
79
-		'requirements' => array('image' => '.+')
80
-	],
28
+    [
29
+        'name' => 'Theming#updateStylesheet',
30
+        'url' => '/ajax/updateStylesheet',
31
+        'verb' => 'POST'
32
+    ],
33
+    [
34
+        'name' => 'Theming#undo',
35
+        'url' => '/ajax/undoChanges',
36
+        'verb' => 'POST'
37
+    ],
38
+    [
39
+        'name' => 'Theming#updateLogo',
40
+        'url' => '/ajax/updateLogo',
41
+        'verb' => 'POST'
42
+    ],
43
+    [
44
+        'name' => 'Theming#getStylesheet',
45
+        'url' => '/styles',
46
+        'verb' => 'GET',
47
+    ],
48
+    [
49
+        'name' => 'Theming#getLogo',
50
+        'url' => '/logo',
51
+        'verb' => 'GET',
52
+    ],
53
+    [
54
+        'name' => 'Theming#getLoginBackground',
55
+        'url' => '/loginbackground',
56
+        'verb' => 'GET',
57
+    ],
58
+    [
59
+        'name' => 'Theming#getJavascript',
60
+        'url' => '/js/theming',
61
+        'verb' => 'GET',
62
+    ],
63
+    [
64
+        'name'	=> 'Icon#getFavicon',
65
+        'url' => '/favicon/{app}',
66
+        'verb' => 'GET',
67
+        'defaults' => array('app' => 'core'),
68
+    ],
69
+    [
70
+        'name'	=> 'Icon#getTouchIcon',
71
+        'url' => '/icon/{app}',
72
+        'verb' => 'GET',
73
+        'defaults' => array('app' => 'core'),
74
+    ],
75
+    [
76
+        'name'	=> 'Icon#getThemedIcon',
77
+        'url' => '/img/{app}/{image}',
78
+        'verb' => 'GET',
79
+        'requirements' => array('image' => '.+')
80
+    ],
81 81
 ]];
82 82
 
Please login to merge, or discard this patch.
apps/theming/appinfo/app.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -24,31 +24,31 @@
 block discarded – undo
24 24
  */
25 25
 
26 26
 $linkToCSS = \OC::$server->getURLGenerator()->linkToRoute(
27
-	'theming.Theming.getStylesheet',
28
-	[
29
-		'v' => \OC::$server->getConfig()->getAppValue('theming', 'cachebuster', '0'),
30
-	]
27
+    'theming.Theming.getStylesheet',
28
+    [
29
+        'v' => \OC::$server->getConfig()->getAppValue('theming', 'cachebuster', '0'),
30
+    ]
31 31
 );
32 32
 \OCP\Util::addHeader(
33
-	'link',
34
-	[
35
-		'rel' => 'stylesheet',
36
-		'href' => $linkToCSS,
37
-	]
33
+    'link',
34
+    [
35
+        'rel' => 'stylesheet',
36
+        'href' => $linkToCSS,
37
+    ]
38 38
 );
39 39
 
40 40
 $linkToJs = \OC::$server->getURLGenerator()->linkToRoute(
41
-	'theming.Theming.getJavascript',
42
-	[
43
-		'v' => \OC::$server->getConfig()->getAppValue('theming', 'cachebuster', '0'),
44
-	]
41
+    'theming.Theming.getJavascript',
42
+    [
43
+        'v' => \OC::$server->getConfig()->getAppValue('theming', 'cachebuster', '0'),
44
+    ]
45 45
 );
46 46
 \OCP\Util::addHeader(
47
-	'script',
48
-	[
49
-		'src' => $linkToJs,
50
-		'nonce' => \OC::$server->getContentSecurityPolicyNonceManager()->getNonce()
51
-	], ''
47
+    'script',
48
+    [
49
+        'src' => $linkToJs,
50
+        'nonce' => \OC::$server->getContentSecurityPolicyNonceManager()->getNonce()
51
+    ], ''
52 52
 );
53 53
 
54 54
 $app = new \OCP\AppFramework\App('theming');
Please login to merge, or discard this patch.
apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -30,73 +30,73 @@
 block discarded – undo
30 30
 
31 31
 class BackupCodesProvider implements IProvider {
32 32
 
33
-	/** @var BackupCodeStorage */
34
-	private $storage;
33
+    /** @var BackupCodeStorage */
34
+    private $storage;
35 35
 
36
-	/** @var IL10N */
37
-	private $l10n;
36
+    /** @var IL10N */
37
+    private $l10n;
38 38
 
39
-	public function __construct(BackupCodeStorage $storage, IL10N $l10n) {
40
-		$this->l10n = $l10n;
41
-		$this->storage = $storage;
42
-	}
39
+    public function __construct(BackupCodeStorage $storage, IL10N $l10n) {
40
+        $this->l10n = $l10n;
41
+        $this->storage = $storage;
42
+    }
43 43
 
44
-	/**
45
-	 * Get unique identifier of this 2FA provider
46
-	 *
47
-	 * @return string
48
-	 */
49
-	public function getId() {
50
-		return 'backup_codes';
51
-	}
44
+    /**
45
+     * Get unique identifier of this 2FA provider
46
+     *
47
+     * @return string
48
+     */
49
+    public function getId() {
50
+        return 'backup_codes';
51
+    }
52 52
 
53
-	/**
54
-	 * Get the display name for selecting the 2FA provider
55
-	 *
56
-	 * @return string
57
-	 */
58
-	public function getDisplayName() {
59
-		return $this->l10n->t('Backup code');
60
-	}
53
+    /**
54
+     * Get the display name for selecting the 2FA provider
55
+     *
56
+     * @return string
57
+     */
58
+    public function getDisplayName() {
59
+        return $this->l10n->t('Backup code');
60
+    }
61 61
 
62
-	/**
63
-	 * Get the description for selecting the 2FA provider
64
-	 *
65
-	 * @return string
66
-	 */
67
-	public function getDescription() {
68
-		return $this->l10n->t('Use backup code');
69
-	}
62
+    /**
63
+     * Get the description for selecting the 2FA provider
64
+     *
65
+     * @return string
66
+     */
67
+    public function getDescription() {
68
+        return $this->l10n->t('Use backup code');
69
+    }
70 70
 
71
-	/**
72
-	 * Get the template for rending the 2FA provider view
73
-	 *
74
-	 * @param IUser $user
75
-	 * @return Template
76
-	 */
77
-	public function getTemplate(IUser $user) {
78
-		$tmpl = new Template('twofactor_backupcodes', 'challenge');
79
-		return $tmpl;
80
-	}
71
+    /**
72
+     * Get the template for rending the 2FA provider view
73
+     *
74
+     * @param IUser $user
75
+     * @return Template
76
+     */
77
+    public function getTemplate(IUser $user) {
78
+        $tmpl = new Template('twofactor_backupcodes', 'challenge');
79
+        return $tmpl;
80
+    }
81 81
 
82
-	/**
83
-	 * Verify the given challenge
84
-	 *
85
-	 * @param IUser $user
86
-	 * @param string $challenge
87
-	 */
88
-	public function verifyChallenge(IUser $user, $challenge) {
89
-		return $this->storage->validateCode($user, $challenge);
90
-	}
82
+    /**
83
+     * Verify the given challenge
84
+     *
85
+     * @param IUser $user
86
+     * @param string $challenge
87
+     */
88
+    public function verifyChallenge(IUser $user, $challenge) {
89
+        return $this->storage->validateCode($user, $challenge);
90
+    }
91 91
 
92
-	/**
93
-	 * Decides whether 2FA is enabled for the given user
94
-	 *
95
-	 * @param IUser $user
96
-	 * @return boolean
97
-	 */
98
-	public function isTwoFactorAuthEnabledForUser(IUser $user) {
99
-		return $this->storage->hasBackupCodes($user);
100
-	}
92
+    /**
93
+     * Decides whether 2FA is enabled for the given user
94
+     *
95
+     * @param IUser $user
96
+     * @return boolean
97
+     */
98
+    public function isTwoFactorAuthEnabledForUser(IUser $user) {
99
+        return $this->storage->hasBackupCodes($user);
100
+    }
101 101
 
102 102
 }
Please login to merge, or discard this patch.
apps/twofactor_backupcodes/lib/Activity/Provider.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -31,42 +31,42 @@
 block discarded – undo
31 31
 
32 32
 class Provider implements IProvider {
33 33
 
34
-	/** @var L10nFactory */
35
-	private $l10n;
34
+    /** @var L10nFactory */
35
+    private $l10n;
36 36
 
37
-	/** @var IURLGenerator */
38
-	private $urlGenerator;
37
+    /** @var IURLGenerator */
38
+    private $urlGenerator;
39 39
 
40
-	/** @var ILogger */
41
-	private $logger;
40
+    /** @var ILogger */
41
+    private $logger;
42 42
 
43
-	/**
44
-	 * @param L10nFactory $l10n
45
-	 * @param IURLGenerator $urlGenerator
46
-	 * @param ILogger $logger
47
-	 */
48
-	public function __construct(L10nFactory $l10n, IURLGenerator $urlGenerator, ILogger $logger) {
49
-		$this->logger = $logger;
50
-		$this->urlGenerator = $urlGenerator;
51
-		$this->l10n = $l10n;
52
-	}
43
+    /**
44
+     * @param L10nFactory $l10n
45
+     * @param IURLGenerator $urlGenerator
46
+     * @param ILogger $logger
47
+     */
48
+    public function __construct(L10nFactory $l10n, IURLGenerator $urlGenerator, ILogger $logger) {
49
+        $this->logger = $logger;
50
+        $this->urlGenerator = $urlGenerator;
51
+        $this->l10n = $l10n;
52
+    }
53 53
 
54
-	public function parse($language, IEvent $event, IEvent $previousEvent = null) {
55
-		if ($event->getApp() !== 'twofactor_backupcodes') {
56
-			throw new InvalidArgumentException();
57
-		}
54
+    public function parse($language, IEvent $event, IEvent $previousEvent = null) {
55
+        if ($event->getApp() !== 'twofactor_backupcodes') {
56
+            throw new InvalidArgumentException();
57
+        }
58 58
 
59
-		$l = $this->l10n->get('twofactor_backupcodes', $language);
59
+        $l = $this->l10n->get('twofactor_backupcodes', $language);
60 60
 
61
-		switch ($event->getSubject()) {
62
-			case 'codes_generated':
63
-				$event->setParsedSubject($l->t('You created two-factor backup codes for your account'));
64
-				$event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg')));
65
-				break;
66
-			default:
67
-				throw new InvalidArgumentException();
68
-		}
69
-		return $event;
70
-	}
61
+        switch ($event->getSubject()) {
62
+            case 'codes_generated':
63
+                $event->setParsedSubject($l->t('You created two-factor backup codes for your account'));
64
+                $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg')));
65
+                break;
66
+            default:
67
+                throw new InvalidArgumentException();
68
+        }
69
+        return $event;
70
+    }
71 71
 
72 72
 }
Please login to merge, or discard this patch.
apps/twofactor_backupcodes/lib/Activity/GenericProvider.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -31,47 +31,47 @@
 block discarded – undo
31 31
 
32 32
 class GenericProvider implements IProvider {
33 33
 
34
-	/** @var L10nFactory */
35
-	private $l10n;
34
+    /** @var L10nFactory */
35
+    private $l10n;
36 36
 
37
-	/** @var IURLGenerator */
38
-	private $urlGenerator;
37
+    /** @var IURLGenerator */
38
+    private $urlGenerator;
39 39
 
40
-	/** @var ILogger */
41
-	private $logger;
40
+    /** @var ILogger */
41
+    private $logger;
42 42
 
43
-	public function __construct(L10nFactory $l10n, IURLGenerator $urlGenerator, ILogger $logger) {
44
-		$this->logger = $logger;
45
-		$this->urlGenerator = $urlGenerator;
46
-		$this->l10n = $l10n;
47
-	}
43
+    public function __construct(L10nFactory $l10n, IURLGenerator $urlGenerator, ILogger $logger) {
44
+        $this->logger = $logger;
45
+        $this->urlGenerator = $urlGenerator;
46
+        $this->l10n = $l10n;
47
+    }
48 48
 
49
-	public function parse($language, IEvent $event, IEvent $previousEvent = null) {
50
-		if ($event->getType() !== 'twofactor') {
51
-			throw new InvalidArgumentException();
52
-		}
49
+    public function parse($language, IEvent $event, IEvent $previousEvent = null) {
50
+        if ($event->getType() !== 'twofactor') {
51
+            throw new InvalidArgumentException();
52
+        }
53 53
 
54
-		$l = $this->l10n->get('core', $language);
54
+        $l = $this->l10n->get('core', $language);
55 55
 
56
-		switch ($event->getSubject()) {
57
-			case 'twofactor_success':
58
-				$params = $event->getSubjectParameters();
59
-				$event->setParsedSubject($l->t('You successfully logged in using two-factor authentication (%1$s)', [
60
-							$params['provider'],
61
-					]));
62
-				$event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg')));
63
-				break;
64
-			case 'twofactor_failed':
65
-				$params = $event->getSubjectParameters();
66
-				$event->setParsedSubject($l->t('A login attempt using two-factor authentication failed (%1$s)', [
67
-							$params['provider'],
68
-					]));
69
-				$event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg')));
70
-				break;
71
-			default:
72
-				throw new InvalidArgumentException();
73
-		}
74
-		return $event;
75
-	}
56
+        switch ($event->getSubject()) {
57
+            case 'twofactor_success':
58
+                $params = $event->getSubjectParameters();
59
+                $event->setParsedSubject($l->t('You successfully logged in using two-factor authentication (%1$s)', [
60
+                            $params['provider'],
61
+                    ]));
62
+                $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg')));
63
+                break;
64
+            case 'twofactor_failed':
65
+                $params = $event->getSubjectParameters();
66
+                $event->setParsedSubject($l->t('A login attempt using two-factor authentication failed (%1$s)', [
67
+                            $params['provider'],
68
+                    ]));
69
+                $event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg')));
70
+                break;
71
+            default:
72
+                throw new InvalidArgumentException();
73
+        }
74
+        return $event;
75
+    }
76 76
 
77 77
 }
Please login to merge, or discard this patch.
apps/twofactor_backupcodes/lib/Activity/GenericFilter.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -28,39 +28,39 @@
 block discarded – undo
28 28
 
29 29
 class GenericFilter implements IFilter {
30 30
 
31
-	/** @var IURLGenerator */
32
-	private $urlGenerator;
31
+    /** @var IURLGenerator */
32
+    private $urlGenerator;
33 33
 
34
-	/** @var IL10N */
35
-	private $l10n;
34
+    /** @var IL10N */
35
+    private $l10n;
36 36
 
37
-	public function __construct(IURLGenerator $urlGenerator, IL10N $l10n) {
38
-		$this->urlGenerator = $urlGenerator;
39
-		$this->l10n = $l10n;
40
-	}
37
+    public function __construct(IURLGenerator $urlGenerator, IL10N $l10n) {
38
+        $this->urlGenerator = $urlGenerator;
39
+        $this->l10n = $l10n;
40
+    }
41 41
 
42
-	public function allowedApps() {
43
-		return [];
44
-	}
42
+    public function allowedApps() {
43
+        return [];
44
+    }
45 45
 
46
-	public function filterTypes(array $types) {
47
-		return array_intersect(['twofactor'], $types);
48
-	}
46
+    public function filterTypes(array $types) {
47
+        return array_intersect(['twofactor'], $types);
48
+    }
49 49
 
50
-	public function getIcon() {
51
-		return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg'));
52
-	}
50
+    public function getIcon() {
51
+        return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg'));
52
+    }
53 53
 
54
-	public function getIdentifier() {
55
-		return 'twofactor';
56
-	}
54
+    public function getIdentifier() {
55
+        return 'twofactor';
56
+    }
57 57
 
58
-	public function getName() {
59
-		return $this->l10n->t('Two-factor authentication');
60
-	}
58
+    public function getName() {
59
+        return $this->l10n->t('Two-factor authentication');
60
+    }
61 61
 
62
-	public function getPriority() {
63
-		return 30;
64
-	}
62
+    public function getPriority() {
63
+        return 30;
64
+    }
65 65
 
66 66
 }
Please login to merge, or discard this patch.
apps/twofactor_backupcodes/lib/Activity/GenericSetting.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -27,39 +27,39 @@
 block discarded – undo
27 27
 
28 28
 class GenericSetting implements ISetting {
29 29
 
30
-	/** @var IL10N */
31
-	private $l10n;
30
+    /** @var IL10N */
31
+    private $l10n;
32 32
 
33
-	public function __construct(IL10N $l10n) {
34
-		$this->l10n = $l10n;
35
-	}
33
+    public function __construct(IL10N $l10n) {
34
+        $this->l10n = $l10n;
35
+    }
36 36
 
37
-	public function canChangeMail() {
38
-		return false;
39
-	}
37
+    public function canChangeMail() {
38
+        return false;
39
+    }
40 40
 
41
-	public function canChangeStream() {
42
-		return false;
43
-	}
41
+    public function canChangeStream() {
42
+        return false;
43
+    }
44 44
 
45
-	public function getIdentifier() {
46
-		return 'twofactor';
47
-	}
45
+    public function getIdentifier() {
46
+        return 'twofactor';
47
+    }
48 48
 
49
-	public function getName() {
50
-		return $this->l10n->t('Two-factor authentication');
51
-	}
49
+    public function getName() {
50
+        return $this->l10n->t('Two-factor authentication');
51
+    }
52 52
 
53
-	public function getPriority() {
54
-		return 30;
55
-	}
53
+    public function getPriority() {
54
+        return 30;
55
+    }
56 56
 
57
-	public function isDefaultEnabledMail() {
58
-		return true;
59
-	}
57
+    public function isDefaultEnabledMail() {
58
+        return true;
59
+    }
60 60
 
61
-	public function isDefaultEnabledStream() {
62
-		return true;
63
-	}
61
+    public function isDefaultEnabledStream() {
62
+        return true;
63
+    }
64 64
 
65 65
 }
Please login to merge, or discard this patch.
apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php 1 patch
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -33,133 +33,133 @@
 block discarded – undo
33 33
 
34 34
 class BackupCodeStorage {
35 35
 
36
-	private static $CODE_LENGTH = 16;
37
-
38
-	/** @var BackupCodeMapper */
39
-	private $mapper;
40
-
41
-	/** @var IHasher */
42
-	private $hasher;
43
-
44
-	/** @var ISecureRandom */
45
-	private $random;
46
-
47
-	/** @var IManager */
48
-	private $activityManager;
49
-
50
-	/** @var ILogger */
51
-	private $logger;
52
-
53
-	/**
54
-	 * @param BackupCodeMapper $mapper
55
-	 * @param ISecureRandom $random
56
-	 * @param IHasher $hasher
57
-	 * @param IManager $activityManager
58
-	 * @param ILogger $logger
59
-	 */
60
-	public function __construct(BackupCodeMapper $mapper, ISecureRandom $random, IHasher $hasher,
61
-		IManager $activityManager, ILogger $logger) {
62
-		$this->mapper = $mapper;
63
-		$this->hasher = $hasher;
64
-		$this->random = $random;
65
-		$this->activityManager = $activityManager;
66
-		$this->logger = $logger;
67
-	}
68
-
69
-	/**
70
-	 * @param IUser $user
71
-	 * @return string[]
72
-	 */
73
-	public function createCodes(IUser $user, $number = 10) {
74
-		$result = [];
75
-
76
-		// Delete existing ones
77
-		$this->mapper->deleteCodes($user);
78
-
79
-		$uid = $user->getUID();
80
-		foreach (range(1, min([$number, 20])) as $i) {
81
-			$code = $this->random->generate(self::$CODE_LENGTH, ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS);
82
-
83
-			$dbCode = new BackupCode();
84
-			$dbCode->setUserId($uid);
85
-			$dbCode->setCode($this->hasher->hash($code));
86
-			$dbCode->setUsed(0);
87
-			$this->mapper->insert($dbCode);
88
-
89
-			array_push($result, $code);
90
-		}
91
-
92
-		$this->publishEvent($user, 'codes_generated');
93
-
94
-		return $result;
95
-	}
96
-
97
-	/**
98
-	 * Push an event the user's activity stream
99
-	 *
100
-	 * @param IUser $user
101
-	 * @param string $event
102
-	 */
103
-	private function publishEvent(IUser $user, $event) {
104
-		$activity = $this->activityManager->generateEvent();
105
-		$activity->setApp('twofactor_backupcodes')
106
-			->setType('twofactor')
107
-			->setAuthor($user->getUID())
108
-			->setAffectedUser($user->getUID())
109
-			->setSubject($event);
110
-		try {
111
-			$this->activityManager->publish($activity);
112
-		} catch (BadMethodCallException $e) {
113
-			$this->logger->warning('could not publish backup code creation activity', ['app' => 'twofactor_backupcodes']);
114
-			$this->logger->logException($e, ['app' => 'twofactor_backupcodes']);
115
-		}
116
-	}
117
-
118
-	/**
119
-	 * @param IUser $user
120
-	 * @return bool
121
-	 */
122
-	public function hasBackupCodes(IUser $user) {
123
-		$codes = $this->mapper->getBackupCodes($user);
124
-		return count($codes) > 0;
125
-	}
126
-
127
-	/**
128
-	 * @param IUser $user
129
-	 * @return array
130
-	 */
131
-	public function getBackupCodesState(IUser $user) {
132
-		$codes = $this->mapper->getBackupCodes($user);
133
-		$total = count($codes);
134
-		$used = 0;
135
-		array_walk($codes, function (BackupCode $code) use (&$used) {
136
-			if (1 === (int) $code->getUsed()) {
137
-				$used++;
138
-			}
139
-		});
140
-		return [
141
-			'enabled' => $total > 0,
142
-			'total' => $total,
143
-			'used' => $used,
144
-		];
145
-	}
146
-
147
-	/**
148
-	 * @param IUser $user
149
-	 * @param string $code
150
-	 * @return bool
151
-	 */
152
-	public function validateCode(IUser $user, $code) {
153
-		$dbCodes = $this->mapper->getBackupCodes($user);
154
-
155
-		foreach ($dbCodes as $dbCode) {
156
-			if (0 === (int) $dbCode->getUsed() && $this->hasher->verify($code, $dbCode->getCode())) {
157
-				$dbCode->setUsed(1);
158
-				$this->mapper->update($dbCode);
159
-				return true;
160
-			}
161
-		}
162
-		return false;
163
-	}
36
+    private static $CODE_LENGTH = 16;
37
+
38
+    /** @var BackupCodeMapper */
39
+    private $mapper;
40
+
41
+    /** @var IHasher */
42
+    private $hasher;
43
+
44
+    /** @var ISecureRandom */
45
+    private $random;
46
+
47
+    /** @var IManager */
48
+    private $activityManager;
49
+
50
+    /** @var ILogger */
51
+    private $logger;
52
+
53
+    /**
54
+     * @param BackupCodeMapper $mapper
55
+     * @param ISecureRandom $random
56
+     * @param IHasher $hasher
57
+     * @param IManager $activityManager
58
+     * @param ILogger $logger
59
+     */
60
+    public function __construct(BackupCodeMapper $mapper, ISecureRandom $random, IHasher $hasher,
61
+        IManager $activityManager, ILogger $logger) {
62
+        $this->mapper = $mapper;
63
+        $this->hasher = $hasher;
64
+        $this->random = $random;
65
+        $this->activityManager = $activityManager;
66
+        $this->logger = $logger;
67
+    }
68
+
69
+    /**
70
+     * @param IUser $user
71
+     * @return string[]
72
+     */
73
+    public function createCodes(IUser $user, $number = 10) {
74
+        $result = [];
75
+
76
+        // Delete existing ones
77
+        $this->mapper->deleteCodes($user);
78
+
79
+        $uid = $user->getUID();
80
+        foreach (range(1, min([$number, 20])) as $i) {
81
+            $code = $this->random->generate(self::$CODE_LENGTH, ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS);
82
+
83
+            $dbCode = new BackupCode();
84
+            $dbCode->setUserId($uid);
85
+            $dbCode->setCode($this->hasher->hash($code));
86
+            $dbCode->setUsed(0);
87
+            $this->mapper->insert($dbCode);
88
+
89
+            array_push($result, $code);
90
+        }
91
+
92
+        $this->publishEvent($user, 'codes_generated');
93
+
94
+        return $result;
95
+    }
96
+
97
+    /**
98
+     * Push an event the user's activity stream
99
+     *
100
+     * @param IUser $user
101
+     * @param string $event
102
+     */
103
+    private function publishEvent(IUser $user, $event) {
104
+        $activity = $this->activityManager->generateEvent();
105
+        $activity->setApp('twofactor_backupcodes')
106
+            ->setType('twofactor')
107
+            ->setAuthor($user->getUID())
108
+            ->setAffectedUser($user->getUID())
109
+            ->setSubject($event);
110
+        try {
111
+            $this->activityManager->publish($activity);
112
+        } catch (BadMethodCallException $e) {
113
+            $this->logger->warning('could not publish backup code creation activity', ['app' => 'twofactor_backupcodes']);
114
+            $this->logger->logException($e, ['app' => 'twofactor_backupcodes']);
115
+        }
116
+    }
117
+
118
+    /**
119
+     * @param IUser $user
120
+     * @return bool
121
+     */
122
+    public function hasBackupCodes(IUser $user) {
123
+        $codes = $this->mapper->getBackupCodes($user);
124
+        return count($codes) > 0;
125
+    }
126
+
127
+    /**
128
+     * @param IUser $user
129
+     * @return array
130
+     */
131
+    public function getBackupCodesState(IUser $user) {
132
+        $codes = $this->mapper->getBackupCodes($user);
133
+        $total = count($codes);
134
+        $used = 0;
135
+        array_walk($codes, function (BackupCode $code) use (&$used) {
136
+            if (1 === (int) $code->getUsed()) {
137
+                $used++;
138
+            }
139
+        });
140
+        return [
141
+            'enabled' => $total > 0,
142
+            'total' => $total,
143
+            'used' => $used,
144
+        ];
145
+    }
146
+
147
+    /**
148
+     * @param IUser $user
149
+     * @param string $code
150
+     * @return bool
151
+     */
152
+    public function validateCode(IUser $user, $code) {
153
+        $dbCodes = $this->mapper->getBackupCodes($user);
154
+
155
+        foreach ($dbCodes as $dbCode) {
156
+            if (0 === (int) $dbCode->getUsed() && $this->hasher->verify($code, $dbCode->getCode())) {
157
+                $dbCode->setUsed(1);
158
+                $this->mapper->update($dbCode);
159
+                return true;
160
+            }
161
+        }
162
+        return false;
163
+    }
164 164
 
165 165
 }
Please login to merge, or discard this patch.