Completed
Push — master ( 67d04f...ac3300 )
by Morris
14:00
created
core/routes.php 1 patch
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -36,53 +36,53 @@  discard block
 block discarded – undo
36 36
 
37 37
 $application = new Application();
38 38
 $application->registerRoutes($this, [
39
-	'routes' => [
40
-		['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'],
41
-		['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'],
42
-		['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'],
43
-		['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'],
44
-		['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'],
45
-		['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'],
46
-		['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'],
47
-		['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'],
48
-		['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'],
49
-		['name' => 'CSRFToken#index', 'url' => '/csrftoken', 'verb' => 'GET'],
50
-		['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'],
51
-		['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'],
52
-		['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'],
53
-		['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'],
54
-		['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'],
55
-		['name' => 'ClientFlowLogin#redirectPage', 'url' => '/login/flow/redirect', 'verb' => 'GET'],
56
-		['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'],
57
-		['name' => 'ClientFlowLogin#grantPage', 'url' => '/login/flow/grant', 'verb' => 'GET'],
58
-		['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'],
59
-		['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'],
60
-		['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'],
61
-		['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'],
62
-		['name' => 'Preview#getPreviewByFileId', 'url' => '/core/preview', 'verb' => 'GET'],
63
-		['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'],
64
-		['name' => 'Svg#getSvgFromCore', 'url' => '/svg/core/{folder}/{fileName}/{color}', 'verb' => 'GET'],
65
-		['name' => 'Svg#getSvgFromSettings', 'url' => '/svg/settings/{folder}/{fileName}/{color}', 'verb' => 'GET'],
66
-		['name' => 'Svg#getSvgFromApp', 'url' => '/svg/{app}/{fileName}/{color}', 'verb' => 'GET'],
67
-		['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'],
68
-		['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'],
69
-		['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'],
70
-		['name' => 'contactsMenu#findOne', 'url' => '/contactsmenu/findOne', 'verb' => 'POST'],
71
-		['name' => 'WalledGarden#get', 'url' => '/204', 'verb' => 'GET'],
72
-		['name' => 'Search#search', 'url' => '/core/search', 'verb' => 'GET'],
73
-	],
74
-	'ocs' => [
75
-		['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'],
76
-		['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'],
77
-		['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'],
78
-		['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'],
79
-		['root' => '/core', 'name' => 'Navigation#getAppsNavigation', 'url' => '/navigation/apps', 'verb' => 'GET'],
80
-		['root' => '/core', 'name' => 'Navigation#getSettingsNavigation', 'url' => '/navigation/settings', 'verb' => 'GET'],
81
-		['root' => '/core', 'name' => 'AutoComplete#get', 'url' => '/autocomplete/get', 'verb' => 'GET'],
82
-		['root' => '/core', 'name' => 'WhatsNew#get', 'url' => '/whatsnew', 'verb' => 'GET'],
83
-		['root' => '/core', 'name' => 'WhatsNew#dismiss', 'url' => '/whatsnew', 'verb' => 'POST'],
84
-		['root' => '/core', 'name' => 'AppPassword#getAppPassword', 'url' => '/getapppassword', 'verb' => 'GET'],
85
-	],
39
+    'routes' => [
40
+        ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'],
41
+        ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'],
42
+        ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'],
43
+        ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'],
44
+        ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'],
45
+        ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'],
46
+        ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'],
47
+        ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'],
48
+        ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'],
49
+        ['name' => 'CSRFToken#index', 'url' => '/csrftoken', 'verb' => 'GET'],
50
+        ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'],
51
+        ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'],
52
+        ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'],
53
+        ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'],
54
+        ['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'],
55
+        ['name' => 'ClientFlowLogin#redirectPage', 'url' => '/login/flow/redirect', 'verb' => 'GET'],
56
+        ['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'],
57
+        ['name' => 'ClientFlowLogin#grantPage', 'url' => '/login/flow/grant', 'verb' => 'GET'],
58
+        ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'],
59
+        ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'],
60
+        ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'],
61
+        ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'],
62
+        ['name' => 'Preview#getPreviewByFileId', 'url' => '/core/preview', 'verb' => 'GET'],
63
+        ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'],
64
+        ['name' => 'Svg#getSvgFromCore', 'url' => '/svg/core/{folder}/{fileName}/{color}', 'verb' => 'GET'],
65
+        ['name' => 'Svg#getSvgFromSettings', 'url' => '/svg/settings/{folder}/{fileName}/{color}', 'verb' => 'GET'],
66
+        ['name' => 'Svg#getSvgFromApp', 'url' => '/svg/{app}/{fileName}/{color}', 'verb' => 'GET'],
67
+        ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'],
68
+        ['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'],
69
+        ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'],
70
+        ['name' => 'contactsMenu#findOne', 'url' => '/contactsmenu/findOne', 'verb' => 'POST'],
71
+        ['name' => 'WalledGarden#get', 'url' => '/204', 'verb' => 'GET'],
72
+        ['name' => 'Search#search', 'url' => '/core/search', 'verb' => 'GET'],
73
+    ],
74
+    'ocs' => [
75
+        ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'],
76
+        ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'],
77
+        ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'],
78
+        ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'],
79
+        ['root' => '/core', 'name' => 'Navigation#getAppsNavigation', 'url' => '/navigation/apps', 'verb' => 'GET'],
80
+        ['root' => '/core', 'name' => 'Navigation#getSettingsNavigation', 'url' => '/navigation/settings', 'verb' => 'GET'],
81
+        ['root' => '/core', 'name' => 'AutoComplete#get', 'url' => '/autocomplete/get', 'verb' => 'GET'],
82
+        ['root' => '/core', 'name' => 'WhatsNew#get', 'url' => '/whatsnew', 'verb' => 'GET'],
83
+        ['root' => '/core', 'name' => 'WhatsNew#dismiss', 'url' => '/whatsnew', 'verb' => 'POST'],
84
+        ['root' => '/core', 'name' => 'AppPassword#getAppPassword', 'url' => '/getapppassword', 'verb' => 'GET'],
85
+    ],
86 86
 ]);
87 87
 
88 88
 // Post installation check
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
 // Core ajax actions
92 92
 // Routing
93 93
 $this->create('core_ajax_update', '/core/ajax/update.php')
94
-	->actionInclude('core/ajax/update.php');
94
+    ->actionInclude('core/ajax/update.php');
95 95
 
96 96
 // File routes
97 97
 $this->create('files.viewcontroller.showFile', '/f/{fileid}')->action(function($urlParams) {
98
-	$app = new \OCA\Files\AppInfo\Application($urlParams);
99
-	$app->dispatch('ViewController', 'index');
98
+    $app = new \OCA\Files\AppInfo\Application($urlParams);
99
+    $app->dispatch('ViewController', 'index');
100 100
 });
101 101
 
102 102
 // Call routes
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
  * @suppress PhanUndeclaredClassMethod
106 106
  */
107 107
 $this->create('spreed.pagecontroller.showCall', '/call/{token}')->action(function($urlParams) {
108
-	if (class_exists(\OCA\Spreed\AppInfo\Application::class, false)) {
109
-		$app = new \OCA\Spreed\AppInfo\Application($urlParams);
110
-		$app->dispatch('PageController', 'index');
111
-	} else {
112
-		throw new \OC\HintException('App spreed is not enabled');
113
-	}
108
+    if (class_exists(\OCA\Spreed\AppInfo\Application::class, false)) {
109
+        $app = new \OCA\Spreed\AppInfo\Application($urlParams);
110
+        $app->dispatch('PageController', 'index');
111
+    } else {
112
+        throw new \OC\HintException('App spreed is not enabled');
113
+    }
114 114
 });
115 115
 
116 116
 // OCM routes
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
  * @suppress PhanUndeclaredClassMethod
120 120
  */
121 121
 $this->create('cloud_federation_api.requesthandlercontroller.addShare', '/ocm/shares')->post()->action(function($urlParams) {
122
-	if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) {
123
-		$app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams);
124
-		$app->dispatch('RequestHandlerController', 'addShare');
125
-	} else {
126
-		throw new \OC\HintException('Cloud Federation API not enabled');
127
-	}
122
+    if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) {
123
+        $app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams);
124
+        $app->dispatch('RequestHandlerController', 'addShare');
125
+    } else {
126
+        throw new \OC\HintException('Cloud Federation API not enabled');
127
+    }
128 128
 });
129 129
 
130 130
 /**
@@ -132,53 +132,53 @@  discard block
 block discarded – undo
132 132
  * @suppress PhanUndeclaredClassMethod
133 133
  */
134 134
 $this->create('cloud_federation_api.requesthandlercontroller.receiveNotification', '/ocm/notifications')->post()->action(function($urlParams) {
135
-	if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) {
136
-		$app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams);
137
-		$app->dispatch('RequestHandlerController', 'receiveNotification');
138
-	} else {
139
-		throw new \OC\HintException('Cloud Federation API not enabled');
140
-	}
135
+    if (class_exists(\OCA\CloudFederationAPI\AppInfo\Application::class, false)) {
136
+        $app = new \OCA\CloudFederationAPI\AppInfo\Application($urlParams);
137
+        $app->dispatch('RequestHandlerController', 'receiveNotification');
138
+    } else {
139
+        throw new \OC\HintException('Cloud Federation API not enabled');
140
+    }
141 141
 });
142 142
 
143 143
 
144 144
 // Sharing routes
145 145
 $this->create('files_sharing.sharecontroller.showShare', '/s/{token}')->action(function($urlParams) {
146
-	if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
147
-		$app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
148
-		$app->dispatch('ShareController', 'showShare');
149
-	} else {
150
-		throw new \OC\HintException('App file sharing is not enabled');
151
-	}
146
+    if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
147
+        $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
148
+        $app->dispatch('ShareController', 'showShare');
149
+    } else {
150
+        throw new \OC\HintException('App file sharing is not enabled');
151
+    }
152 152
 });
153 153
 $this->create('files_sharing.sharecontroller.authenticate', '/s/{token}/authenticate/{redirect}')->post()->action(function($urlParams) {
154
-	if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
155
-		$app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
156
-		$app->dispatch('ShareController', 'authenticate');
157
-	} else {
158
-		throw new \OC\HintException('App file sharing is not enabled');
159
-	}
154
+    if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
155
+        $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
156
+        $app->dispatch('ShareController', 'authenticate');
157
+    } else {
158
+        throw new \OC\HintException('App file sharing is not enabled');
159
+    }
160 160
 });
161 161
 $this->create('files_sharing.sharecontroller.showAuthenticate', '/s/{token}/authenticate/{redirect}')->get()->action(function($urlParams) {
162
-	if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
163
-		$app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
164
-		$app->dispatch('ShareController', 'showAuthenticate');
165
-	} else {
166
-		throw new \OC\HintException('App file sharing is not enabled');
167
-	}
162
+    if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
163
+        $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
164
+        $app->dispatch('ShareController', 'showAuthenticate');
165
+    } else {
166
+        throw new \OC\HintException('App file sharing is not enabled');
167
+    }
168 168
 });
169 169
 $this->create('files_sharing.sharecontroller.downloadShare', '/s/{token}/download')->get()->action(function($urlParams) {
170
-	if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
171
-		$app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
172
-		$app->dispatch('ShareController', 'downloadShare');
173
-	} else {
174
-		throw new \OC\HintException('App file sharing is not enabled');
175
-	}
170
+    if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
171
+        $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
172
+        $app->dispatch('ShareController', 'downloadShare');
173
+    } else {
174
+        throw new \OC\HintException('App file sharing is not enabled');
175
+    }
176 176
 });
177 177
 $this->create('files_sharing.publicpreview.directLink', '/s/{token}/preview')->get()->action(function($urlParams) {
178
-	if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
179
-		$app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
180
-		$app->dispatch('PublicPreviewController', 'directLink');
181
-	} else {
182
-		throw new \OC\HintException('App file sharing is not enabled');
183
-	}
178
+    if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) {
179
+        $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams);
180
+        $app->dispatch('PublicPreviewController', 'directLink');
181
+    } else {
182
+        throw new \OC\HintException('App file sharing is not enabled');
183
+    }
184 184
 });
Please login to merge, or discard this patch.
core/Controller/AppPasswordController.php 1 patch
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -37,72 +37,72 @@
 block discarded – undo
37 37
 
38 38
 class AppPasswordController extends \OCP\AppFramework\OCSController {
39 39
 
40
-	/** @var ISession */
41
-	private $session;
42
-
43
-	/** @var ISecureRandom */
44
-	private $random;
45
-
46
-	/** @var IProvider */
47
-	private $tokenProvider;
48
-
49
-	/** @var IStore */
50
-	private $credentialStore;
51
-
52
-	public function __construct(string $appName,
53
-								IRequest $request,
54
-								ISession $session,
55
-								ISecureRandom $random,
56
-								IProvider $tokenProvider,
57
-								IStore $credentialStore) {
58
-		parent::__construct($appName, $request);
59
-
60
-		$this->session = $session;
61
-		$this->random = $random;
62
-		$this->tokenProvider = $tokenProvider;
63
-		$this->credentialStore = $credentialStore;
64
-	}
65
-
66
-	/**
67
-	 * @NoAdminRequired
68
-	 *
69
-	 * @return DataResponse
70
-	 * @throws OCSForbiddenException
71
-	 */
72
-	public function getAppPassword(): DataResponse {
73
-		// We do not allow the creation of new tokens if this is an app password
74
-		if ($this->session->exists('app_password')) {
75
-			throw new OCSForbiddenException('You cannot request an new apppassword with an apppassword');
76
-		}
77
-
78
-		try {
79
-			$credentials = $this->credentialStore->getLoginCredentials();
80
-		} catch (CredentialsUnavailableException $e) {
81
-			throw new OCSForbiddenException();
82
-		}
83
-
84
-		try {
85
-			$password = $credentials->getPassword();
86
-		} catch (PasswordUnavailableException $e) {
87
-			$password = null;
88
-		}
89
-
90
-		$userAgent = $this->request->getHeader('USER_AGENT');
91
-
92
-		$token = $this->random->generate(72, ISecureRandom::CHAR_UPPER.ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_DIGITS);
93
-
94
-		$this->tokenProvider->generateToken(
95
-			$token,
96
-			$credentials->getUID(),
97
-			$credentials->getLoginName(),
98
-			$password,
99
-			$userAgent,
100
-			IToken::PERMANENT_TOKEN,
101
-			IToken::DO_NOT_REMEMBER
102
-		);
103
-
104
-		return new DataResponse([
105
-			'apppassword' => $token
106
-		]);
107
-	}
40
+    /** @var ISession */
41
+    private $session;
42
+
43
+    /** @var ISecureRandom */
44
+    private $random;
45
+
46
+    /** @var IProvider */
47
+    private $tokenProvider;
48
+
49
+    /** @var IStore */
50
+    private $credentialStore;
51
+
52
+    public function __construct(string $appName,
53
+                                IRequest $request,
54
+                                ISession $session,
55
+                                ISecureRandom $random,
56
+                                IProvider $tokenProvider,
57
+                                IStore $credentialStore) {
58
+        parent::__construct($appName, $request);
59
+
60
+        $this->session = $session;
61
+        $this->random = $random;
62
+        $this->tokenProvider = $tokenProvider;
63
+        $this->credentialStore = $credentialStore;
64
+    }
65
+
66
+    /**
67
+     * @NoAdminRequired
68
+     *
69
+     * @return DataResponse
70
+     * @throws OCSForbiddenException
71
+     */
72
+    public function getAppPassword(): DataResponse {
73
+        // We do not allow the creation of new tokens if this is an app password
74
+        if ($this->session->exists('app_password')) {
75
+            throw new OCSForbiddenException('You cannot request an new apppassword with an apppassword');
76
+        }
77
+
78
+        try {
79
+            $credentials = $this->credentialStore->getLoginCredentials();
80
+        } catch (CredentialsUnavailableException $e) {
81
+            throw new OCSForbiddenException();
82
+        }
83
+
84
+        try {
85
+            $password = $credentials->getPassword();
86
+        } catch (PasswordUnavailableException $e) {
87
+            $password = null;
88
+        }
89
+
90
+        $userAgent = $this->request->getHeader('USER_AGENT');
91
+
92
+        $token = $this->random->generate(72, ISecureRandom::CHAR_UPPER.ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_DIGITS);
93
+
94
+        $this->tokenProvider->generateToken(
95
+            $token,
96
+            $credentials->getUID(),
97
+            $credentials->getLoginName(),
98
+            $password,
99
+            $userAgent,
100
+            IToken::PERMANENT_TOKEN,
101
+            IToken::DO_NOT_REMEMBER
102
+        );
103
+
104
+        return new DataResponse([
105
+            'apppassword' => $token
106
+        ]);
107
+    }
108 108
 }
Please login to merge, or discard this patch.