Completed
Push — master ( a67720...be1982 )
by Daniel
19:40 queued 14s
created
lib/private/User/Backend.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -39,14 +39,14 @@  discard block
 block discarded – undo
39 39
 	/**
40 40
 	 * actions that user backends can define
41 41
 	 */
42
-	public const CREATE_USER = 1;			// 1 << 0
43
-	public const SET_PASSWORD = 16;			// 1 << 4
44
-	public const CHECK_PASSWORD = 256;			// 1 << 8
45
-	public const GET_HOME = 4096;			// 1 << 12
46
-	public const GET_DISPLAYNAME = 65536;		// 1 << 16
47
-	public const SET_DISPLAYNAME = 1048576;		// 1 << 20
48
-	public const PROVIDE_AVATAR = 16777216;		// 1 << 24
49
-	public const COUNT_USERS = 268435456;	// 1 << 28
42
+	public const CREATE_USER = 1; // 1 << 0
43
+	public const SET_PASSWORD = 16; // 1 << 4
44
+	public const CHECK_PASSWORD = 256; // 1 << 8
45
+	public const GET_HOME = 4096; // 1 << 12
46
+	public const GET_DISPLAYNAME = 65536; // 1 << 16
47
+	public const SET_DISPLAYNAME = 1048576; // 1 << 20
48
+	public const PROVIDE_AVATAR = 16777216; // 1 << 24
49
+	public const COUNT_USERS = 268435456; // 1 << 28
50 50
 
51 51
 	protected $possibleActions = [
52 52
 		self::CREATE_USER => 'createUser',
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 * compared with self::CREATE_USER etc.
87 87
 	 */
88 88
 	public function implementsActions($actions) {
89
-		return (bool)($this->getSupportedActions() & $actions);
89
+		return (bool) ($this->getSupportedActions() & $actions);
90 90
 	}
91 91
 
92 92
 	/**
Please login to merge, or discard this patch.
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -14,136 +14,136 @@
 block discarded – undo
14 14
  * capabilities.
15 15
  */
16 16
 abstract class Backend implements UserInterface {
17
-	/**
18
-	 * error code for functions not provided by the user backend
19
-	 */
20
-	public const NOT_IMPLEMENTED = -501;
17
+    /**
18
+     * error code for functions not provided by the user backend
19
+     */
20
+    public const NOT_IMPLEMENTED = -501;
21 21
 
22
-	/**
23
-	 * actions that user backends can define
24
-	 */
25
-	public const CREATE_USER = 1;			// 1 << 0
26
-	public const SET_PASSWORD = 16;			// 1 << 4
27
-	public const CHECK_PASSWORD = 256;			// 1 << 8
28
-	public const GET_HOME = 4096;			// 1 << 12
29
-	public const GET_DISPLAYNAME = 65536;		// 1 << 16
30
-	public const SET_DISPLAYNAME = 1048576;		// 1 << 20
31
-	public const PROVIDE_AVATAR = 16777216;		// 1 << 24
32
-	public const COUNT_USERS = 268435456;	// 1 << 28
22
+    /**
23
+     * actions that user backends can define
24
+     */
25
+    public const CREATE_USER = 1;			// 1 << 0
26
+    public const SET_PASSWORD = 16;			// 1 << 4
27
+    public const CHECK_PASSWORD = 256;			// 1 << 8
28
+    public const GET_HOME = 4096;			// 1 << 12
29
+    public const GET_DISPLAYNAME = 65536;		// 1 << 16
30
+    public const SET_DISPLAYNAME = 1048576;		// 1 << 20
31
+    public const PROVIDE_AVATAR = 16777216;		// 1 << 24
32
+    public const COUNT_USERS = 268435456;	// 1 << 28
33 33
 
34
-	protected $possibleActions = [
35
-		self::CREATE_USER => 'createUser',
36
-		self::SET_PASSWORD => 'setPassword',
37
-		self::CHECK_PASSWORD => 'checkPassword',
38
-		self::GET_HOME => 'getHome',
39
-		self::GET_DISPLAYNAME => 'getDisplayName',
40
-		self::SET_DISPLAYNAME => 'setDisplayName',
41
-		self::PROVIDE_AVATAR => 'canChangeAvatar',
42
-		self::COUNT_USERS => 'countUsers',
43
-	];
34
+    protected $possibleActions = [
35
+        self::CREATE_USER => 'createUser',
36
+        self::SET_PASSWORD => 'setPassword',
37
+        self::CHECK_PASSWORD => 'checkPassword',
38
+        self::GET_HOME => 'getHome',
39
+        self::GET_DISPLAYNAME => 'getDisplayName',
40
+        self::SET_DISPLAYNAME => 'setDisplayName',
41
+        self::PROVIDE_AVATAR => 'canChangeAvatar',
42
+        self::COUNT_USERS => 'countUsers',
43
+    ];
44 44
 
45
-	/**
46
-	 * Get all supported actions
47
-	 * @return int bitwise-or'ed actions
48
-	 *
49
-	 * Returns the supported actions as int to be
50
-	 * compared with self::CREATE_USER etc.
51
-	 */
52
-	public function getSupportedActions() {
53
-		$actions = 0;
54
-		foreach ($this->possibleActions as $action => $methodName) {
55
-			if (method_exists($this, $methodName)) {
56
-				$actions |= $action;
57
-			}
58
-		}
45
+    /**
46
+     * Get all supported actions
47
+     * @return int bitwise-or'ed actions
48
+     *
49
+     * Returns the supported actions as int to be
50
+     * compared with self::CREATE_USER etc.
51
+     */
52
+    public function getSupportedActions() {
53
+        $actions = 0;
54
+        foreach ($this->possibleActions as $action => $methodName) {
55
+            if (method_exists($this, $methodName)) {
56
+                $actions |= $action;
57
+            }
58
+        }
59 59
 
60
-		return $actions;
61
-	}
60
+        return $actions;
61
+    }
62 62
 
63
-	/**
64
-	 * Check if backend implements actions
65
-	 * @param int $actions bitwise-or'ed actions
66
-	 * @return boolean
67
-	 *
68
-	 * Returns the supported actions as int to be
69
-	 * compared with self::CREATE_USER etc.
70
-	 */
71
-	public function implementsActions($actions) {
72
-		return (bool)($this->getSupportedActions() & $actions);
73
-	}
63
+    /**
64
+     * Check if backend implements actions
65
+     * @param int $actions bitwise-or'ed actions
66
+     * @return boolean
67
+     *
68
+     * Returns the supported actions as int to be
69
+     * compared with self::CREATE_USER etc.
70
+     */
71
+    public function implementsActions($actions) {
72
+        return (bool)($this->getSupportedActions() & $actions);
73
+    }
74 74
 
75
-	/**
76
-	 * delete a user
77
-	 * @param string $uid The username of the user to delete
78
-	 * @return bool
79
-	 *
80
-	 * Deletes a user
81
-	 */
82
-	public function deleteUser($uid) {
83
-		return false;
84
-	}
75
+    /**
76
+     * delete a user
77
+     * @param string $uid The username of the user to delete
78
+     * @return bool
79
+     *
80
+     * Deletes a user
81
+     */
82
+    public function deleteUser($uid) {
83
+        return false;
84
+    }
85 85
 
86
-	/**
87
-	 * Get a list of all users
88
-	 *
89
-	 * @param string $search
90
-	 * @param null|int $limit
91
-	 * @param null|int $offset
92
-	 * @return string[] an array of all uids
93
-	 */
94
-	public function getUsers($search = '', $limit = null, $offset = null) {
95
-		return [];
96
-	}
86
+    /**
87
+     * Get a list of all users
88
+     *
89
+     * @param string $search
90
+     * @param null|int $limit
91
+     * @param null|int $offset
92
+     * @return string[] an array of all uids
93
+     */
94
+    public function getUsers($search = '', $limit = null, $offset = null) {
95
+        return [];
96
+    }
97 97
 
98
-	/**
99
-	 * check if a user exists
100
-	 * @param string $uid the username
101
-	 * @return boolean
102
-	 */
103
-	public function userExists($uid) {
104
-		return false;
105
-	}
98
+    /**
99
+     * check if a user exists
100
+     * @param string $uid the username
101
+     * @return boolean
102
+     */
103
+    public function userExists($uid) {
104
+        return false;
105
+    }
106 106
 
107
-	/**
108
-	 * get the user's home directory
109
-	 * @param string $uid the username
110
-	 * @return string|boolean
111
-	 */
112
-	public function getHome(string $uid) {
113
-		return false;
114
-	}
107
+    /**
108
+     * get the user's home directory
109
+     * @param string $uid the username
110
+     * @return string|boolean
111
+     */
112
+    public function getHome(string $uid) {
113
+        return false;
114
+    }
115 115
 
116
-	/**
117
-	 * get display name of the user
118
-	 * @param string $uid user ID of the user
119
-	 * @return string display name
120
-	 */
121
-	public function getDisplayName($uid) {
122
-		return $uid;
123
-	}
116
+    /**
117
+     * get display name of the user
118
+     * @param string $uid user ID of the user
119
+     * @return string display name
120
+     */
121
+    public function getDisplayName($uid) {
122
+        return $uid;
123
+    }
124 124
 
125
-	/**
126
-	 * Get a list of all display names and user ids.
127
-	 *
128
-	 * @param string $search
129
-	 * @param int|null $limit
130
-	 * @param int|null $offset
131
-	 * @return array an array of all displayNames (value) and the corresponding uids (key)
132
-	 */
133
-	public function getDisplayNames($search = '', $limit = null, $offset = null) {
134
-		$displayNames = [];
135
-		$users = $this->getUsers($search, $limit, $offset);
136
-		foreach ($users as $user) {
137
-			$displayNames[$user] = $user;
138
-		}
139
-		return $displayNames;
140
-	}
125
+    /**
126
+     * Get a list of all display names and user ids.
127
+     *
128
+     * @param string $search
129
+     * @param int|null $limit
130
+     * @param int|null $offset
131
+     * @return array an array of all displayNames (value) and the corresponding uids (key)
132
+     */
133
+    public function getDisplayNames($search = '', $limit = null, $offset = null) {
134
+        $displayNames = [];
135
+        $users = $this->getUsers($search, $limit, $offset);
136
+        foreach ($users as $user) {
137
+            $displayNames[$user] = $user;
138
+        }
139
+        return $displayNames;
140
+    }
141 141
 
142
-	/**
143
-	 * Check if a user list is available or not
144
-	 * @return boolean if users can be listed or not
145
-	 */
146
-	public function hasUserListings() {
147
-		return false;
148
-	}
142
+    /**
143
+     * Check if a user list is available or not
144
+     * @return boolean if users can be listed or not
145
+     */
146
+    public function hasUserListings() {
147
+        return false;
148
+    }
149 149
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/Middleware/Security/SameSiteCookieMiddleware.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@
 block discarded – undo
95 95
 		foreach ($policies as $policy) {
96 96
 			header(
97 97
 				sprintf(
98
-					'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;' . $secureCookie . 'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s',
98
+					'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;'.$secureCookie.'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s',
99 99
 					$cookiePrefix,
100 100
 					$policy,
101 101
 					$cookieParams['path'],
Please login to merge, or discard this patch.
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -13,76 +13,76 @@
 block discarded – undo
13 13
 use OCP\AppFramework\Middleware;
14 14
 
15 15
 class SameSiteCookieMiddleware extends Middleware {
16
-	/** @var Request */
17
-	private $request;
16
+    /** @var Request */
17
+    private $request;
18 18
 
19
-	/** @var ControllerMethodReflector */
20
-	private $reflector;
19
+    /** @var ControllerMethodReflector */
20
+    private $reflector;
21 21
 
22
-	public function __construct(Request $request,
23
-		ControllerMethodReflector $reflector) {
24
-		$this->request = $request;
25
-		$this->reflector = $reflector;
26
-	}
22
+    public function __construct(Request $request,
23
+        ControllerMethodReflector $reflector) {
24
+        $this->request = $request;
25
+        $this->reflector = $reflector;
26
+    }
27 27
 
28
-	public function beforeController($controller, $methodName) {
29
-		$requestUri = $this->request->getScriptName();
30
-		$processingScript = explode('/', $requestUri);
31
-		$processingScript = $processingScript[count($processingScript) - 1];
28
+    public function beforeController($controller, $methodName) {
29
+        $requestUri = $this->request->getScriptName();
30
+        $processingScript = explode('/', $requestUri);
31
+        $processingScript = $processingScript[count($processingScript) - 1];
32 32
 
33
-		if ($processingScript !== 'index.php') {
34
-			return;
35
-		}
33
+        if ($processingScript !== 'index.php') {
34
+            return;
35
+        }
36 36
 
37
-		$noSSC = $this->reflector->hasAnnotation('NoSameSiteCookieRequired');
38
-		if ($noSSC) {
39
-			return;
40
-		}
37
+        $noSSC = $this->reflector->hasAnnotation('NoSameSiteCookieRequired');
38
+        if ($noSSC) {
39
+            return;
40
+        }
41 41
 
42
-		if (!$this->request->passesLaxCookieCheck()) {
43
-			throw new LaxSameSiteCookieFailedException();
44
-		}
45
-	}
42
+        if (!$this->request->passesLaxCookieCheck()) {
43
+            throw new LaxSameSiteCookieFailedException();
44
+        }
45
+    }
46 46
 
47
-	public function afterException($controller, $methodName, \Exception $exception) {
48
-		if ($exception instanceof LaxSameSiteCookieFailedException) {
49
-			$response = new Response();
50
-			$response->setStatus(Http::STATUS_FOUND);
51
-			$response->addHeader('Location', $this->request->getRequestUri());
47
+    public function afterException($controller, $methodName, \Exception $exception) {
48
+        if ($exception instanceof LaxSameSiteCookieFailedException) {
49
+            $response = new Response();
50
+            $response->setStatus(Http::STATUS_FOUND);
51
+            $response->addHeader('Location', $this->request->getRequestUri());
52 52
 
53
-			$this->setSameSiteCookie();
53
+            $this->setSameSiteCookie();
54 54
 
55
-			return $response;
56
-		}
55
+            return $response;
56
+        }
57 57
 
58
-		throw $exception;
59
-	}
58
+        throw $exception;
59
+    }
60 60
 
61
-	protected function setSameSiteCookie() {
62
-		$cookieParams = $this->request->getCookieParams();
63
-		$secureCookie = ($cookieParams['secure'] === true) ? 'secure; ' : '';
64
-		$policies = [
65
-			'lax',
66
-			'strict',
67
-		];
61
+    protected function setSameSiteCookie() {
62
+        $cookieParams = $this->request->getCookieParams();
63
+        $secureCookie = ($cookieParams['secure'] === true) ? 'secure; ' : '';
64
+        $policies = [
65
+            'lax',
66
+            'strict',
67
+        ];
68 68
 
69
-		// Append __Host to the cookie if it meets the requirements
70
-		$cookiePrefix = '';
71
-		if ($cookieParams['secure'] === true && $cookieParams['path'] === '/') {
72
-			$cookiePrefix = '__Host-';
73
-		}
69
+        // Append __Host to the cookie if it meets the requirements
70
+        $cookiePrefix = '';
71
+        if ($cookieParams['secure'] === true && $cookieParams['path'] === '/') {
72
+            $cookiePrefix = '__Host-';
73
+        }
74 74
 
75
-		foreach ($policies as $policy) {
76
-			header(
77
-				sprintf(
78
-					'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;' . $secureCookie . 'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s',
79
-					$cookiePrefix,
80
-					$policy,
81
-					$cookieParams['path'],
82
-					$policy
83
-				),
84
-				false
85
-			);
86
-		}
87
-	}
75
+        foreach ($policies as $policy) {
76
+            header(
77
+                sprintf(
78
+                    'Set-Cookie: %snc_sameSiteCookie%s=true; path=%s; httponly;' . $secureCookie . 'expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=%s',
79
+                    $cookiePrefix,
80
+                    $policy,
81
+                    $cookieParams['path'],
82
+                    $policy
83
+                ),
84
+                false
85
+            );
86
+        }
87
+    }
88 88
 }
Please login to merge, or discard this patch.
lib/private/AppFramework/Http.php 2 patches
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -33,99 +33,99 @@
 block discarded – undo
33 33
 use OCP\AppFramework\Http as BaseHttp;
34 34
 
35 35
 class Http extends BaseHttp {
36
-	private $server;
37
-	private $protocolVersion;
38
-	protected $headers;
36
+    private $server;
37
+    private $protocolVersion;
38
+    protected $headers;
39 39
 
40
-	/**
41
-	 * @param array $server $_SERVER
42
-	 * @param string $protocolVersion the http version to use defaults to HTTP/1.1
43
-	 */
44
-	public function __construct($server, $protocolVersion = 'HTTP/1.1') {
45
-		$this->server = $server;
46
-		$this->protocolVersion = $protocolVersion;
40
+    /**
41
+     * @param array $server $_SERVER
42
+     * @param string $protocolVersion the http version to use defaults to HTTP/1.1
43
+     */
44
+    public function __construct($server, $protocolVersion = 'HTTP/1.1') {
45
+        $this->server = $server;
46
+        $this->protocolVersion = $protocolVersion;
47 47
 
48
-		$this->headers = [
49
-			self::STATUS_CONTINUE => 'Continue',
50
-			self::STATUS_SWITCHING_PROTOCOLS => 'Switching Protocols',
51
-			self::STATUS_PROCESSING => 'Processing',
52
-			self::STATUS_OK => 'OK',
53
-			self::STATUS_CREATED => 'Created',
54
-			self::STATUS_ACCEPTED => 'Accepted',
55
-			self::STATUS_NON_AUTHORATIVE_INFORMATION => 'Non-Authorative Information',
56
-			self::STATUS_NO_CONTENT => 'No Content',
57
-			self::STATUS_RESET_CONTENT => 'Reset Content',
58
-			self::STATUS_PARTIAL_CONTENT => 'Partial Content',
59
-			self::STATUS_MULTI_STATUS => 'Multi-Status', // RFC 4918
60
-			self::STATUS_ALREADY_REPORTED => 'Already Reported', // RFC 5842
61
-			self::STATUS_IM_USED => 'IM Used', // RFC 3229
62
-			self::STATUS_MULTIPLE_CHOICES => 'Multiple Choices',
63
-			self::STATUS_MOVED_PERMANENTLY => 'Moved Permanently',
64
-			self::STATUS_FOUND => 'Found',
65
-			self::STATUS_SEE_OTHER => 'See Other',
66
-			self::STATUS_NOT_MODIFIED => 'Not Modified',
67
-			self::STATUS_USE_PROXY => 'Use Proxy',
68
-			self::STATUS_RESERVED => 'Reserved',
69
-			self::STATUS_TEMPORARY_REDIRECT => 'Temporary Redirect',
70
-			self::STATUS_BAD_REQUEST => 'Bad request',
71
-			self::STATUS_UNAUTHORIZED => 'Unauthorized',
72
-			self::STATUS_PAYMENT_REQUIRED => 'Payment Required',
73
-			self::STATUS_FORBIDDEN => 'Forbidden',
74
-			self::STATUS_NOT_FOUND => 'Not Found',
75
-			self::STATUS_METHOD_NOT_ALLOWED => 'Method Not Allowed',
76
-			self::STATUS_NOT_ACCEPTABLE => 'Not Acceptable',
77
-			self::STATUS_PROXY_AUTHENTICATION_REQUIRED => 'Proxy Authentication Required',
78
-			self::STATUS_REQUEST_TIMEOUT => 'Request Timeout',
79
-			self::STATUS_CONFLICT => 'Conflict',
80
-			self::STATUS_GONE => 'Gone',
81
-			self::STATUS_LENGTH_REQUIRED => 'Length Required',
82
-			self::STATUS_PRECONDITION_FAILED => 'Precondition failed',
83
-			self::STATUS_REQUEST_ENTITY_TOO_LARGE => 'Request Entity Too Large',
84
-			self::STATUS_REQUEST_URI_TOO_LONG => 'Request-URI Too Long',
85
-			self::STATUS_UNSUPPORTED_MEDIA_TYPE => 'Unsupported Media Type',
86
-			self::STATUS_REQUEST_RANGE_NOT_SATISFIABLE => 'Requested Range Not Satisfiable',
87
-			self::STATUS_EXPECTATION_FAILED => 'Expectation Failed',
88
-			self::STATUS_IM_A_TEAPOT => 'I\'m a teapot', // RFC 2324
89
-			self::STATUS_UNPROCESSABLE_ENTITY => 'Unprocessable Entity', // RFC 4918
90
-			self::STATUS_LOCKED => 'Locked', // RFC 4918
91
-			self::STATUS_FAILED_DEPENDENCY => 'Failed Dependency', // RFC 4918
92
-			self::STATUS_UPGRADE_REQUIRED => 'Upgrade required',
93
-			self::STATUS_PRECONDITION_REQUIRED => 'Precondition required', // draft-nottingham-http-new-status
94
-			self::STATUS_TOO_MANY_REQUESTS => 'Too Many Requests', // draft-nottingham-http-new-status
95
-			self::STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE => 'Request Header Fields Too Large', // draft-nottingham-http-new-status
96
-			self::STATUS_INTERNAL_SERVER_ERROR => 'Internal Server Error',
97
-			self::STATUS_NOT_IMPLEMENTED => 'Not Implemented',
98
-			self::STATUS_BAD_GATEWAY => 'Bad Gateway',
99
-			self::STATUS_SERVICE_UNAVAILABLE => 'Service Unavailable',
100
-			self::STATUS_GATEWAY_TIMEOUT => 'Gateway Timeout',
101
-			self::STATUS_HTTP_VERSION_NOT_SUPPORTED => 'HTTP Version not supported',
102
-			self::STATUS_VARIANT_ALSO_NEGOTIATES => 'Variant Also Negotiates',
103
-			self::STATUS_INSUFFICIENT_STORAGE => 'Insufficient Storage', // RFC 4918
104
-			self::STATUS_LOOP_DETECTED => 'Loop Detected', // RFC 5842
105
-			self::STATUS_BANDWIDTH_LIMIT_EXCEEDED => 'Bandwidth Limit Exceeded', // non-standard
106
-			self::STATUS_NOT_EXTENDED => 'Not extended',
107
-			self::STATUS_NETWORK_AUTHENTICATION_REQUIRED => 'Network Authentication Required', // draft-nottingham-http-new-status
108
-		];
109
-	}
48
+        $this->headers = [
49
+            self::STATUS_CONTINUE => 'Continue',
50
+            self::STATUS_SWITCHING_PROTOCOLS => 'Switching Protocols',
51
+            self::STATUS_PROCESSING => 'Processing',
52
+            self::STATUS_OK => 'OK',
53
+            self::STATUS_CREATED => 'Created',
54
+            self::STATUS_ACCEPTED => 'Accepted',
55
+            self::STATUS_NON_AUTHORATIVE_INFORMATION => 'Non-Authorative Information',
56
+            self::STATUS_NO_CONTENT => 'No Content',
57
+            self::STATUS_RESET_CONTENT => 'Reset Content',
58
+            self::STATUS_PARTIAL_CONTENT => 'Partial Content',
59
+            self::STATUS_MULTI_STATUS => 'Multi-Status', // RFC 4918
60
+            self::STATUS_ALREADY_REPORTED => 'Already Reported', // RFC 5842
61
+            self::STATUS_IM_USED => 'IM Used', // RFC 3229
62
+            self::STATUS_MULTIPLE_CHOICES => 'Multiple Choices',
63
+            self::STATUS_MOVED_PERMANENTLY => 'Moved Permanently',
64
+            self::STATUS_FOUND => 'Found',
65
+            self::STATUS_SEE_OTHER => 'See Other',
66
+            self::STATUS_NOT_MODIFIED => 'Not Modified',
67
+            self::STATUS_USE_PROXY => 'Use Proxy',
68
+            self::STATUS_RESERVED => 'Reserved',
69
+            self::STATUS_TEMPORARY_REDIRECT => 'Temporary Redirect',
70
+            self::STATUS_BAD_REQUEST => 'Bad request',
71
+            self::STATUS_UNAUTHORIZED => 'Unauthorized',
72
+            self::STATUS_PAYMENT_REQUIRED => 'Payment Required',
73
+            self::STATUS_FORBIDDEN => 'Forbidden',
74
+            self::STATUS_NOT_FOUND => 'Not Found',
75
+            self::STATUS_METHOD_NOT_ALLOWED => 'Method Not Allowed',
76
+            self::STATUS_NOT_ACCEPTABLE => 'Not Acceptable',
77
+            self::STATUS_PROXY_AUTHENTICATION_REQUIRED => 'Proxy Authentication Required',
78
+            self::STATUS_REQUEST_TIMEOUT => 'Request Timeout',
79
+            self::STATUS_CONFLICT => 'Conflict',
80
+            self::STATUS_GONE => 'Gone',
81
+            self::STATUS_LENGTH_REQUIRED => 'Length Required',
82
+            self::STATUS_PRECONDITION_FAILED => 'Precondition failed',
83
+            self::STATUS_REQUEST_ENTITY_TOO_LARGE => 'Request Entity Too Large',
84
+            self::STATUS_REQUEST_URI_TOO_LONG => 'Request-URI Too Long',
85
+            self::STATUS_UNSUPPORTED_MEDIA_TYPE => 'Unsupported Media Type',
86
+            self::STATUS_REQUEST_RANGE_NOT_SATISFIABLE => 'Requested Range Not Satisfiable',
87
+            self::STATUS_EXPECTATION_FAILED => 'Expectation Failed',
88
+            self::STATUS_IM_A_TEAPOT => 'I\'m a teapot', // RFC 2324
89
+            self::STATUS_UNPROCESSABLE_ENTITY => 'Unprocessable Entity', // RFC 4918
90
+            self::STATUS_LOCKED => 'Locked', // RFC 4918
91
+            self::STATUS_FAILED_DEPENDENCY => 'Failed Dependency', // RFC 4918
92
+            self::STATUS_UPGRADE_REQUIRED => 'Upgrade required',
93
+            self::STATUS_PRECONDITION_REQUIRED => 'Precondition required', // draft-nottingham-http-new-status
94
+            self::STATUS_TOO_MANY_REQUESTS => 'Too Many Requests', // draft-nottingham-http-new-status
95
+            self::STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE => 'Request Header Fields Too Large', // draft-nottingham-http-new-status
96
+            self::STATUS_INTERNAL_SERVER_ERROR => 'Internal Server Error',
97
+            self::STATUS_NOT_IMPLEMENTED => 'Not Implemented',
98
+            self::STATUS_BAD_GATEWAY => 'Bad Gateway',
99
+            self::STATUS_SERVICE_UNAVAILABLE => 'Service Unavailable',
100
+            self::STATUS_GATEWAY_TIMEOUT => 'Gateway Timeout',
101
+            self::STATUS_HTTP_VERSION_NOT_SUPPORTED => 'HTTP Version not supported',
102
+            self::STATUS_VARIANT_ALSO_NEGOTIATES => 'Variant Also Negotiates',
103
+            self::STATUS_INSUFFICIENT_STORAGE => 'Insufficient Storage', // RFC 4918
104
+            self::STATUS_LOOP_DETECTED => 'Loop Detected', // RFC 5842
105
+            self::STATUS_BANDWIDTH_LIMIT_EXCEEDED => 'Bandwidth Limit Exceeded', // non-standard
106
+            self::STATUS_NOT_EXTENDED => 'Not extended',
107
+            self::STATUS_NETWORK_AUTHENTICATION_REQUIRED => 'Network Authentication Required', // draft-nottingham-http-new-status
108
+        ];
109
+    }
110 110
 
111 111
 
112
-	/**
113
-	 * Gets the correct header
114
-	 * @param int Http::CONSTANT $status the constant from the Http class
115
-	 * @param \DateTime $lastModified formatted last modified date
116
-	 * @param string $ETag the etag
117
-	 * @return string
118
-	 */
119
-	public function getStatusHeader($status) {
120
-		// we have one change currently for the http 1.0 header that differs
121
-		// from 1.1: STATUS_TEMPORARY_REDIRECT should be STATUS_FOUND
122
-		// if this differs any more, we want to create childclasses for this
123
-		if ($status === self::STATUS_TEMPORARY_REDIRECT
124
-			&& $this->protocolVersion === 'HTTP/1.0') {
125
-			$status = self::STATUS_FOUND;
126
-		}
112
+    /**
113
+     * Gets the correct header
114
+     * @param int Http::CONSTANT $status the constant from the Http class
115
+     * @param \DateTime $lastModified formatted last modified date
116
+     * @param string $ETag the etag
117
+     * @return string
118
+     */
119
+    public function getStatusHeader($status) {
120
+        // we have one change currently for the http 1.0 header that differs
121
+        // from 1.1: STATUS_TEMPORARY_REDIRECT should be STATUS_FOUND
122
+        // if this differs any more, we want to create childclasses for this
123
+        if ($status === self::STATUS_TEMPORARY_REDIRECT
124
+            && $this->protocolVersion === 'HTTP/1.0') {
125
+            $status = self::STATUS_FOUND;
126
+        }
127 127
 
128
-		return $this->protocolVersion . ' ' . $status . ' ' .
129
-			$this->headers[$status];
130
-	}
128
+        return $this->protocolVersion . ' ' . $status . ' ' .
129
+            $this->headers[$status];
130
+    }
131 131
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@
 block discarded – undo
125 125
 			$status = self::STATUS_FOUND;
126 126
 		}
127 127
 
128
-		return $this->protocolVersion . ' ' . $status . ' ' .
128
+		return $this->protocolVersion.' '.$status.' '.
129 129
 			$this->headers[$status];
130 130
 	}
131 131
 }
Please login to merge, or discard this patch.
lib/private/Collaboration/Collaborators/GroupPlugin.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 		$result = ['wide' => [], 'exact' => []];
64 64
 
65 65
 		$groups = $this->groupManager->search($search, $limit, $offset);
66
-		$groupIds = array_map(function (IGroup $group) {
66
+		$groupIds = array_map(function(IGroup $group) {
67 67
 			return $group->getGID();
68 68
 		}, $groups);
69 69
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 		if (!empty($groups) && ($this->shareWithGroupOnly || $this->shareeEnumerationInGroupOnly)) {
76 76
 			// Intersect all the groups that match with the groups this user is a member of
77 77
 			$userGroups = $this->groupManager->getUserGroups($this->userSession->getUser());
78
-			$userGroups = array_map(function (IGroup $group) {
78
+			$userGroups = array_map(function(IGroup $group) {
79 79
 				return $group->getGID();
80 80
 			}, $userGroups);
81 81
 			$groupIds = array_intersect($groupIds, $userGroups);
Please login to merge, or discard this patch.
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -15,115 +15,115 @@
 block discarded – undo
15 15
 use OCP\Share\IShare;
16 16
 
17 17
 class GroupPlugin implements ISearchPlugin {
18
-	protected bool $shareeEnumeration;
19
-
20
-	protected bool $shareWithGroupOnly;
21
-
22
-	protected bool $shareeEnumerationInGroupOnly;
23
-
24
-	protected bool $groupSharingDisabled;
25
-
26
-	public function __construct(
27
-		private IConfig $config,
28
-		private IGroupManager $groupManager,
29
-		private IUserSession $userSession,
30
-		private mixed $shareWithGroupOnlyExcludeGroupsList = [],
31
-	) {
32
-		$this->shareeEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes';
33
-		$this->shareWithGroupOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes';
34
-		$this->shareeEnumerationInGroupOnly = $this->shareeEnumeration && $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_group', 'no') === 'yes';
35
-		$this->groupSharingDisabled = $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes') === 'no';
36
-
37
-		if ($this->shareWithGroupOnly) {
38
-			$this->shareWithGroupOnlyExcludeGroupsList = json_decode($this->config->getAppValue('core', 'shareapi_only_share_with_group_members_exclude_group_list', ''), true) ?? [];
39
-		}
40
-	}
41
-
42
-	public function search($search, $limit, $offset, ISearchResult $searchResult): bool {
43
-		if ($this->groupSharingDisabled) {
44
-			return false;
45
-		}
46
-
47
-		$hasMoreResults = false;
48
-		$result = ['wide' => [], 'exact' => []];
49
-
50
-		$groups = $this->groupManager->search($search, $limit, $offset);
51
-		$groupIds = array_map(function (IGroup $group) {
52
-			return $group->getGID();
53
-		}, $groups);
54
-
55
-		if (!$this->shareeEnumeration || count($groups) < $limit) {
56
-			$hasMoreResults = true;
57
-		}
58
-
59
-		$userGroups = [];
60
-		if (!empty($groups) && ($this->shareWithGroupOnly || $this->shareeEnumerationInGroupOnly)) {
61
-			// Intersect all the groups that match with the groups this user is a member of
62
-			$userGroups = $this->groupManager->getUserGroups($this->userSession->getUser());
63
-			$userGroups = array_map(function (IGroup $group) {
64
-				return $group->getGID();
65
-			}, $userGroups);
66
-			$groupIds = array_intersect($groupIds, $userGroups);
67
-
68
-			// ShareWithGroupOnly filtering
69
-			$groupIds = array_diff($groupIds, $this->shareWithGroupOnlyExcludeGroupsList);
70
-		}
71
-
72
-		$lowerSearch = strtolower($search);
73
-		foreach ($groups as $group) {
74
-			if ($group->hideFromCollaboration()) {
75
-				continue;
76
-			}
77
-
78
-			// FIXME: use a more efficient approach
79
-			$gid = $group->getGID();
80
-			if (!in_array($gid, $groupIds)) {
81
-				continue;
82
-			}
83
-			if (strtolower($gid) === $lowerSearch || strtolower($group->getDisplayName()) === $lowerSearch) {
84
-				$result['exact'][] = [
85
-					'label' => $group->getDisplayName(),
86
-					'value' => [
87
-						'shareType' => IShare::TYPE_GROUP,
88
-						'shareWith' => $gid,
89
-					],
90
-				];
91
-			} else {
92
-				if ($this->shareeEnumerationInGroupOnly && !in_array($group->getGID(), $userGroups, true)) {
93
-					continue;
94
-				}
95
-				$result['wide'][] = [
96
-					'label' => $group->getDisplayName(),
97
-					'value' => [
98
-						'shareType' => IShare::TYPE_GROUP,
99
-						'shareWith' => $gid,
100
-					],
101
-				];
102
-			}
103
-		}
104
-
105
-		if ($offset === 0 && empty($result['exact'])) {
106
-			// On page one we try if the search result has a direct hit on the
107
-			// user id and if so, we add that to the exact match list
108
-			$group = $this->groupManager->get($search);
109
-			if ($group instanceof IGroup && !$group->hideFromCollaboration() && (!$this->shareWithGroupOnly || in_array($group->getGID(), $userGroups))) {
110
-				$result['exact'][] = [
111
-					'label' => $group->getDisplayName(),
112
-					'value' => [
113
-						'shareType' => IShare::TYPE_GROUP,
114
-						'shareWith' => $group->getGID(),
115
-					],
116
-				];
117
-			}
118
-		}
119
-
120
-		if (!$this->shareeEnumeration) {
121
-			$result['wide'] = [];
122
-		}
123
-
124
-		$type = new SearchResultType('groups');
125
-		$searchResult->addResultSet($type, $result['wide'], $result['exact']);
126
-
127
-		return $hasMoreResults;
128
-	}
18
+    protected bool $shareeEnumeration;
19
+
20
+    protected bool $shareWithGroupOnly;
21
+
22
+    protected bool $shareeEnumerationInGroupOnly;
23
+
24
+    protected bool $groupSharingDisabled;
25
+
26
+    public function __construct(
27
+        private IConfig $config,
28
+        private IGroupManager $groupManager,
29
+        private IUserSession $userSession,
30
+        private mixed $shareWithGroupOnlyExcludeGroupsList = [],
31
+    ) {
32
+        $this->shareeEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes';
33
+        $this->shareWithGroupOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes';
34
+        $this->shareeEnumerationInGroupOnly = $this->shareeEnumeration && $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_group', 'no') === 'yes';
35
+        $this->groupSharingDisabled = $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes') === 'no';
36
+
37
+        if ($this->shareWithGroupOnly) {
38
+            $this->shareWithGroupOnlyExcludeGroupsList = json_decode($this->config->getAppValue('core', 'shareapi_only_share_with_group_members_exclude_group_list', ''), true) ?? [];
39
+        }
40
+    }
41
+
42
+    public function search($search, $limit, $offset, ISearchResult $searchResult): bool {
43
+        if ($this->groupSharingDisabled) {
44
+            return false;
45
+        }
46
+
47
+        $hasMoreResults = false;
48
+        $result = ['wide' => [], 'exact' => []];
49
+
50
+        $groups = $this->groupManager->search($search, $limit, $offset);
51
+        $groupIds = array_map(function (IGroup $group) {
52
+            return $group->getGID();
53
+        }, $groups);
54
+
55
+        if (!$this->shareeEnumeration || count($groups) < $limit) {
56
+            $hasMoreResults = true;
57
+        }
58
+
59
+        $userGroups = [];
60
+        if (!empty($groups) && ($this->shareWithGroupOnly || $this->shareeEnumerationInGroupOnly)) {
61
+            // Intersect all the groups that match with the groups this user is a member of
62
+            $userGroups = $this->groupManager->getUserGroups($this->userSession->getUser());
63
+            $userGroups = array_map(function (IGroup $group) {
64
+                return $group->getGID();
65
+            }, $userGroups);
66
+            $groupIds = array_intersect($groupIds, $userGroups);
67
+
68
+            // ShareWithGroupOnly filtering
69
+            $groupIds = array_diff($groupIds, $this->shareWithGroupOnlyExcludeGroupsList);
70
+        }
71
+
72
+        $lowerSearch = strtolower($search);
73
+        foreach ($groups as $group) {
74
+            if ($group->hideFromCollaboration()) {
75
+                continue;
76
+            }
77
+
78
+            // FIXME: use a more efficient approach
79
+            $gid = $group->getGID();
80
+            if (!in_array($gid, $groupIds)) {
81
+                continue;
82
+            }
83
+            if (strtolower($gid) === $lowerSearch || strtolower($group->getDisplayName()) === $lowerSearch) {
84
+                $result['exact'][] = [
85
+                    'label' => $group->getDisplayName(),
86
+                    'value' => [
87
+                        'shareType' => IShare::TYPE_GROUP,
88
+                        'shareWith' => $gid,
89
+                    ],
90
+                ];
91
+            } else {
92
+                if ($this->shareeEnumerationInGroupOnly && !in_array($group->getGID(), $userGroups, true)) {
93
+                    continue;
94
+                }
95
+                $result['wide'][] = [
96
+                    'label' => $group->getDisplayName(),
97
+                    'value' => [
98
+                        'shareType' => IShare::TYPE_GROUP,
99
+                        'shareWith' => $gid,
100
+                    ],
101
+                ];
102
+            }
103
+        }
104
+
105
+        if ($offset === 0 && empty($result['exact'])) {
106
+            // On page one we try if the search result has a direct hit on the
107
+            // user id and if so, we add that to the exact match list
108
+            $group = $this->groupManager->get($search);
109
+            if ($group instanceof IGroup && !$group->hideFromCollaboration() && (!$this->shareWithGroupOnly || in_array($group->getGID(), $userGroups))) {
110
+                $result['exact'][] = [
111
+                    'label' => $group->getDisplayName(),
112
+                    'value' => [
113
+                        'shareType' => IShare::TYPE_GROUP,
114
+                        'shareWith' => $group->getGID(),
115
+                    ],
116
+                ];
117
+            }
118
+        }
119
+
120
+        if (!$this->shareeEnumeration) {
121
+            $result['wide'] = [];
122
+        }
123
+
124
+        $type = new SearchResultType('groups');
125
+        $searchResult->addResultSet($type, $result['wide'], $result['exact']);
126
+
127
+        return $hasMoreResults;
128
+    }
129 129
 }
Please login to merge, or discard this patch.
lib/public/Log/IFileBased.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -30,13 +30,13 @@
 block discarded – undo
30 30
  * @since 14.0.0
31 31
  */
32 32
 interface IFileBased {
33
-	/**
34
-	 * @since 14.0.0
35
-	 */
36
-	public function getLogFilePath():string;
33
+    /**
34
+     * @since 14.0.0
35
+     */
36
+    public function getLogFilePath():string;
37 37
 
38
-	/**
39
-	 * @since 14.0.0
40
-	 */
41
-	public function getEntries(int $limit = 50, int $offset = 0): array;
38
+    /**
39
+     * @since 14.0.0
40
+     */
41
+    public function getEntries(int $limit = 50, int $offset = 0): array;
42 42
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/ApiController.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@
 block discarded – undo
86 86
 		$response = new Response();
87 87
 		$response->addHeader('Access-Control-Allow-Origin', $origin);
88 88
 		$response->addHeader('Access-Control-Allow-Methods', $this->corsMethods);
89
-		$response->addHeader('Access-Control-Max-Age', (string)$this->corsMaxAge);
89
+		$response->addHeader('Access-Control-Max-Age', (string) $this->corsMaxAge);
90 90
 		$response->addHeader('Access-Control-Allow-Headers', $this->corsAllowedHeaders);
91 91
 		$response->addHeader('Access-Control-Allow-Credentials', 'false');
92 92
 		return $response;
Please login to merge, or discard this patch.
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -18,58 +18,58 @@
 block discarded – undo
18 18
  * @since 7.0.0
19 19
  */
20 20
 abstract class ApiController extends Controller {
21
-	private $corsMethods;
22
-	private $corsAllowedHeaders;
23
-	private $corsMaxAge;
21
+    private $corsMethods;
22
+    private $corsAllowedHeaders;
23
+    private $corsMaxAge;
24 24
 
25
-	/**
26
-	 * constructor of the controller
27
-	 * @param string $appName the name of the app
28
-	 * @param IRequest $request an instance of the request
29
-	 * @param string $corsMethods comma separated string of HTTP verbs which
30
-	 *                            should be allowed for websites or webapps when calling your API, defaults to
31
-	 *                            'PUT, POST, GET, DELETE, PATCH'
32
-	 * @param string $corsAllowedHeaders comma separated string of HTTP headers
33
-	 *                                   which should be allowed for websites or webapps when calling your API,
34
-	 *                                   defaults to 'Authorization, Content-Type, Accept'
35
-	 * @param int $corsMaxAge number in seconds how long a preflighted OPTIONS
36
-	 *                        request should be cached, defaults to 1728000 seconds
37
-	 * @since 7.0.0
38
-	 */
39
-	public function __construct($appName,
40
-		IRequest $request,
41
-		$corsMethods = 'PUT, POST, GET, DELETE, PATCH',
42
-		$corsAllowedHeaders = 'Authorization, Content-Type, Accept',
43
-		$corsMaxAge = 1728000) {
44
-		parent::__construct($appName, $request);
45
-		$this->corsMethods = $corsMethods;
46
-		$this->corsAllowedHeaders = $corsAllowedHeaders;
47
-		$this->corsMaxAge = $corsMaxAge;
48
-	}
25
+    /**
26
+     * constructor of the controller
27
+     * @param string $appName the name of the app
28
+     * @param IRequest $request an instance of the request
29
+     * @param string $corsMethods comma separated string of HTTP verbs which
30
+     *                            should be allowed for websites or webapps when calling your API, defaults to
31
+     *                            'PUT, POST, GET, DELETE, PATCH'
32
+     * @param string $corsAllowedHeaders comma separated string of HTTP headers
33
+     *                                   which should be allowed for websites or webapps when calling your API,
34
+     *                                   defaults to 'Authorization, Content-Type, Accept'
35
+     * @param int $corsMaxAge number in seconds how long a preflighted OPTIONS
36
+     *                        request should be cached, defaults to 1728000 seconds
37
+     * @since 7.0.0
38
+     */
39
+    public function __construct($appName,
40
+        IRequest $request,
41
+        $corsMethods = 'PUT, POST, GET, DELETE, PATCH',
42
+        $corsAllowedHeaders = 'Authorization, Content-Type, Accept',
43
+        $corsMaxAge = 1728000) {
44
+        parent::__construct($appName, $request);
45
+        $this->corsMethods = $corsMethods;
46
+        $this->corsAllowedHeaders = $corsAllowedHeaders;
47
+        $this->corsMaxAge = $corsMaxAge;
48
+    }
49 49
 
50 50
 
51
-	/**
52
-	 * This method implements a preflighted cors response for you that you can
53
-	 * link to for the options request
54
-	 *
55
-	 * @since 7.0.0
56
-	 */
57
-	#[NoCSRFRequired]
58
-	#[PublicPage]
59
-	#[NoAdminRequired]
60
-	public function preflightedCors() {
61
-		if (isset($this->request->server['HTTP_ORIGIN'])) {
62
-			$origin = $this->request->server['HTTP_ORIGIN'];
63
-		} else {
64
-			$origin = '*';
65
-		}
51
+    /**
52
+     * This method implements a preflighted cors response for you that you can
53
+     * link to for the options request
54
+     *
55
+     * @since 7.0.0
56
+     */
57
+    #[NoCSRFRequired]
58
+    #[PublicPage]
59
+    #[NoAdminRequired]
60
+    public function preflightedCors() {
61
+        if (isset($this->request->server['HTTP_ORIGIN'])) {
62
+            $origin = $this->request->server['HTTP_ORIGIN'];
63
+        } else {
64
+            $origin = '*';
65
+        }
66 66
 
67
-		$response = new Response();
68
-		$response->addHeader('Access-Control-Allow-Origin', $origin);
69
-		$response->addHeader('Access-Control-Allow-Methods', $this->corsMethods);
70
-		$response->addHeader('Access-Control-Max-Age', (string)$this->corsMaxAge);
71
-		$response->addHeader('Access-Control-Allow-Headers', $this->corsAllowedHeaders);
72
-		$response->addHeader('Access-Control-Allow-Credentials', 'false');
73
-		return $response;
74
-	}
67
+        $response = new Response();
68
+        $response->addHeader('Access-Control-Allow-Origin', $origin);
69
+        $response->addHeader('Access-Control-Allow-Methods', $this->corsMethods);
70
+        $response->addHeader('Access-Control-Max-Age', (string)$this->corsMaxAge);
71
+        $response->addHeader('Access-Control-Allow-Headers', $this->corsAllowedHeaders);
72
+        $response->addHeader('Access-Control-Allow-Credentials', 'false');
73
+        return $response;
74
+    }
75 75
 }
Please login to merge, or discard this patch.
lib/public/AppFramework/App.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@
 block discarded – undo
82 82
 
83 83
 		if ($runIsSetupDirectly) {
84 84
 			$applicationClassName = get_class($this);
85
-			$e = new \RuntimeException('App class ' . $applicationClassName . ' is not setup via query() but directly');
85
+			$e = new \RuntimeException('App class '.$applicationClassName.' is not setup via query() but directly');
86 86
 			$setUpViaQuery = false;
87 87
 
88 88
 			$classNameParts = explode('\\', trim($applicationClassName, '\\'));
Please login to merge, or discard this patch.
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -23,140 +23,140 @@
 block discarded – undo
23 23
  * @since 6.0.0
24 24
  */
25 25
 class App {
26
-	/** @var IAppContainer */
27
-	private $container;
28
-
29
-	/**
30
-	 * Turns an app id into a namespace by convention. The id is split at the
31
-	 * underscores, all parts are CamelCased and reassembled. e.g.:
32
-	 * some_app_id -> OCA\SomeAppId
33
-	 * @param string $appId the app id
34
-	 * @param string $topNamespace the namespace which should be prepended to
35
-	 *                             the transformed app id, defaults to OCA\
36
-	 * @return string the starting namespace for the app
37
-	 * @since 8.0.0
38
-	 */
39
-	public static function buildAppNamespace(string $appId, string $topNamespace = 'OCA\\'): string {
40
-		return \OC\AppFramework\App::buildAppNamespace($appId, $topNamespace);
41
-	}
42
-
43
-
44
-	/**
45
-	 * @param string $appName
46
-	 * @param array $urlParams an array with variables extracted from the routes
47
-	 * @since 6.0.0
48
-	 */
49
-	public function __construct(string $appName, array $urlParams = []) {
50
-		$runIsSetupDirectly = \OC::$server->getConfig()->getSystemValueBool('debug')
51
-			&& !ini_get('zend.exception_ignore_args');
52
-
53
-		if ($runIsSetupDirectly) {
54
-			$applicationClassName = get_class($this);
55
-			$e = new \RuntimeException('App class ' . $applicationClassName . ' is not setup via query() but directly');
56
-			$setUpViaQuery = false;
57
-
58
-			$classNameParts = explode('\\', trim($applicationClassName, '\\'));
59
-
60
-			foreach ($e->getTrace() as $step) {
61
-				if (isset($step['class'], $step['function'], $step['args'][0]) &&
62
-					$step['class'] === ServerContainer::class &&
63
-					$step['function'] === 'query' &&
64
-					$step['args'][0] === $applicationClassName) {
65
-					$setUpViaQuery = true;
66
-					break;
67
-				} elseif (isset($step['class'], $step['function'], $step['args'][0]) &&
68
-					$step['class'] === ServerContainer::class &&
69
-					$step['function'] === 'getAppContainer' &&
70
-					$step['args'][1] === $classNameParts[1]) {
71
-					$setUpViaQuery = true;
72
-					break;
73
-				}
74
-			}
75
-
76
-			if (!$setUpViaQuery && $applicationClassName !== \OCP\AppFramework\App::class) {
77
-				\OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), [
78
-					'app' => $appName,
79
-					'exception' => $e,
80
-				]);
81
-			}
82
-		}
83
-
84
-		try {
85
-			$this->container = \OC::$server->getRegisteredAppContainer($appName);
86
-		} catch (QueryException $e) {
87
-			$this->container = new \OC\AppFramework\DependencyInjection\DIContainer($appName, $urlParams);
88
-		}
89
-	}
90
-
91
-	/**
92
-	 * @return IAppContainer
93
-	 * @since 6.0.0
94
-	 */
95
-	public function getContainer(): IAppContainer {
96
-		return $this->container;
97
-	}
98
-
99
-	/**
100
-	 * This function is to be called to create single routes and restful routes based on the given $routes array.
101
-	 *
102
-	 * Example code in routes.php of tasks app (it will register two restful resources):
103
-	 * $routes = array(
104
-	 *		'resources' => array(
105
-	 *		'lists' => array('url' => '/tasklists'),
106
-	 *		'tasks' => array('url' => '/tasklists/{listId}/tasks')
107
-	 *	)
108
-	 *	);
109
-	 *
110
-	 * $a = new TasksApp();
111
-	 * $a->registerRoutes($this, $routes);
112
-	 *
113
-	 * @param \OCP\Route\IRouter $router
114
-	 * @param array $routes
115
-	 * @since 6.0.0
116
-	 * @suppress PhanAccessMethodInternal
117
-	 * @deprecated 20.0.0 Just return an array from your routes.php
118
-	 */
119
-	public function registerRoutes(IRouter $router, array $routes) {
120
-		if (!($router instanceof Router)) {
121
-			throw new \RuntimeException('Can only setup routes with real router');
122
-		}
123
-
124
-		$routeConfig = new RouteConfig($this->container, $router, $routes);
125
-		$routeConfig->register();
126
-	}
127
-
128
-	/**
129
-	 * This function is called by the routing component to fire up the frameworks dispatch mechanism.
130
-	 *
131
-	 * Example code in routes.php of the task app:
132
-	 * $this->create('tasks_index', '/')->get()->action(
133
-	 *		function($params){
134
-	 *			$app = new TaskApp($params);
135
-	 *			$app->dispatch('PageController', 'index');
136
-	 *		}
137
-	 *	);
138
-	 *
139
-	 *
140
-	 * Example for for TaskApp implementation:
141
-	 * class TaskApp extends \OCP\AppFramework\App {
142
-	 *
143
-	 *		public function __construct($params){
144
-	 *			parent::__construct('tasks', $params);
145
-	 *
146
-	 *			$this->getContainer()->registerService('PageController', function(IAppContainer $c){
147
-	 *				$a = $c->query('API');
148
-	 *				$r = $c->query('Request');
149
-	 *				return new PageController($a, $r);
150
-	 *			});
151
-	 *		}
152
-	 *	}
153
-	 *
154
-	 * @param string $controllerName the name of the controller under which it is
155
-	 *                               stored in the DI container
156
-	 * @param string $methodName the method that you want to call
157
-	 * @since 6.0.0
158
-	 */
159
-	public function dispatch(string $controllerName, string $methodName) {
160
-		\OC\AppFramework\App::main($controllerName, $methodName, $this->container);
161
-	}
26
+    /** @var IAppContainer */
27
+    private $container;
28
+
29
+    /**
30
+     * Turns an app id into a namespace by convention. The id is split at the
31
+     * underscores, all parts are CamelCased and reassembled. e.g.:
32
+     * some_app_id -> OCA\SomeAppId
33
+     * @param string $appId the app id
34
+     * @param string $topNamespace the namespace which should be prepended to
35
+     *                             the transformed app id, defaults to OCA\
36
+     * @return string the starting namespace for the app
37
+     * @since 8.0.0
38
+     */
39
+    public static function buildAppNamespace(string $appId, string $topNamespace = 'OCA\\'): string {
40
+        return \OC\AppFramework\App::buildAppNamespace($appId, $topNamespace);
41
+    }
42
+
43
+
44
+    /**
45
+     * @param string $appName
46
+     * @param array $urlParams an array with variables extracted from the routes
47
+     * @since 6.0.0
48
+     */
49
+    public function __construct(string $appName, array $urlParams = []) {
50
+        $runIsSetupDirectly = \OC::$server->getConfig()->getSystemValueBool('debug')
51
+            && !ini_get('zend.exception_ignore_args');
52
+
53
+        if ($runIsSetupDirectly) {
54
+            $applicationClassName = get_class($this);
55
+            $e = new \RuntimeException('App class ' . $applicationClassName . ' is not setup via query() but directly');
56
+            $setUpViaQuery = false;
57
+
58
+            $classNameParts = explode('\\', trim($applicationClassName, '\\'));
59
+
60
+            foreach ($e->getTrace() as $step) {
61
+                if (isset($step['class'], $step['function'], $step['args'][0]) &&
62
+                    $step['class'] === ServerContainer::class &&
63
+                    $step['function'] === 'query' &&
64
+                    $step['args'][0] === $applicationClassName) {
65
+                    $setUpViaQuery = true;
66
+                    break;
67
+                } elseif (isset($step['class'], $step['function'], $step['args'][0]) &&
68
+                    $step['class'] === ServerContainer::class &&
69
+                    $step['function'] === 'getAppContainer' &&
70
+                    $step['args'][1] === $classNameParts[1]) {
71
+                    $setUpViaQuery = true;
72
+                    break;
73
+                }
74
+            }
75
+
76
+            if (!$setUpViaQuery && $applicationClassName !== \OCP\AppFramework\App::class) {
77
+                \OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), [
78
+                    'app' => $appName,
79
+                    'exception' => $e,
80
+                ]);
81
+            }
82
+        }
83
+
84
+        try {
85
+            $this->container = \OC::$server->getRegisteredAppContainer($appName);
86
+        } catch (QueryException $e) {
87
+            $this->container = new \OC\AppFramework\DependencyInjection\DIContainer($appName, $urlParams);
88
+        }
89
+    }
90
+
91
+    /**
92
+     * @return IAppContainer
93
+     * @since 6.0.0
94
+     */
95
+    public function getContainer(): IAppContainer {
96
+        return $this->container;
97
+    }
98
+
99
+    /**
100
+     * This function is to be called to create single routes and restful routes based on the given $routes array.
101
+     *
102
+     * Example code in routes.php of tasks app (it will register two restful resources):
103
+     * $routes = array(
104
+     *		'resources' => array(
105
+     *		'lists' => array('url' => '/tasklists'),
106
+     *		'tasks' => array('url' => '/tasklists/{listId}/tasks')
107
+     *	)
108
+     *	);
109
+     *
110
+     * $a = new TasksApp();
111
+     * $a->registerRoutes($this, $routes);
112
+     *
113
+     * @param \OCP\Route\IRouter $router
114
+     * @param array $routes
115
+     * @since 6.0.0
116
+     * @suppress PhanAccessMethodInternal
117
+     * @deprecated 20.0.0 Just return an array from your routes.php
118
+     */
119
+    public function registerRoutes(IRouter $router, array $routes) {
120
+        if (!($router instanceof Router)) {
121
+            throw new \RuntimeException('Can only setup routes with real router');
122
+        }
123
+
124
+        $routeConfig = new RouteConfig($this->container, $router, $routes);
125
+        $routeConfig->register();
126
+    }
127
+
128
+    /**
129
+     * This function is called by the routing component to fire up the frameworks dispatch mechanism.
130
+     *
131
+     * Example code in routes.php of the task app:
132
+     * $this->create('tasks_index', '/')->get()->action(
133
+     *		function($params){
134
+     *			$app = new TaskApp($params);
135
+     *			$app->dispatch('PageController', 'index');
136
+     *		}
137
+     *	);
138
+     *
139
+     *
140
+     * Example for for TaskApp implementation:
141
+     * class TaskApp extends \OCP\AppFramework\App {
142
+     *
143
+     *		public function __construct($params){
144
+     *			parent::__construct('tasks', $params);
145
+     *
146
+     *			$this->getContainer()->registerService('PageController', function(IAppContainer $c){
147
+     *				$a = $c->query('API');
148
+     *				$r = $c->query('Request');
149
+     *				return new PageController($a, $r);
150
+     *			});
151
+     *		}
152
+     *	}
153
+     *
154
+     * @param string $controllerName the name of the controller under which it is
155
+     *                               stored in the DI container
156
+     * @param string $methodName the method that you want to call
157
+     * @since 6.0.0
158
+     */
159
+    public function dispatch(string $controllerName, string $methodName) {
160
+        \OC\AppFramework\App::main($controllerName, $methodName, $this->container);
161
+    }
162 162
 }
Please login to merge, or discard this patch.
lib/private/Authentication/Listeners/UserDeletedTokenCleanupListener.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
 				$this->manager->invalidateTokenById($uid, $token->getId());
65 65
 			}
66 66
 		} catch (Throwable $e) {
67
-			$this->logger->error('Could not clean up auth tokens after user deletion: ' . $e->getMessage(), [
67
+			$this->logger->error('Could not clean up auth tokens after user deletion: '.$e->getMessage(), [
68 68
 				'exception' => $e,
69 69
 			]);
70 70
 		}
Please login to merge, or discard this patch.
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -19,38 +19,38 @@
 block discarded – undo
19 19
  * @template-implements IEventListener<\OCP\User\Events\UserDeletedEvent>
20 20
  */
21 21
 class UserDeletedTokenCleanupListener implements IEventListener {
22
-	/** @var Manager */
23
-	private $manager;
24
-
25
-	/** @var LoggerInterface */
26
-	private $logger;
27
-
28
-	public function __construct(Manager $manager,
29
-		LoggerInterface $logger) {
30
-		$this->manager = $manager;
31
-		$this->logger = $logger;
32
-	}
33
-
34
-	public function handle(Event $event): void {
35
-		if (!($event instanceof UserDeletedEvent)) {
36
-			// Unrelated
37
-			return;
38
-		}
39
-
40
-		/**
41
-		 * Catch any exception during this process as any failure here shouldn't block the
42
-		 * user deletion.
43
-		 */
44
-		try {
45
-			$uid = $event->getUser()->getUID();
46
-			$tokens = $this->manager->getTokenByUser($uid);
47
-			foreach ($tokens as $token) {
48
-				$this->manager->invalidateTokenById($uid, $token->getId());
49
-			}
50
-		} catch (Throwable $e) {
51
-			$this->logger->error('Could not clean up auth tokens after user deletion: ' . $e->getMessage(), [
52
-				'exception' => $e,
53
-			]);
54
-		}
55
-	}
22
+    /** @var Manager */
23
+    private $manager;
24
+
25
+    /** @var LoggerInterface */
26
+    private $logger;
27
+
28
+    public function __construct(Manager $manager,
29
+        LoggerInterface $logger) {
30
+        $this->manager = $manager;
31
+        $this->logger = $logger;
32
+    }
33
+
34
+    public function handle(Event $event): void {
35
+        if (!($event instanceof UserDeletedEvent)) {
36
+            // Unrelated
37
+            return;
38
+        }
39
+
40
+        /**
41
+         * Catch any exception during this process as any failure here shouldn't block the
42
+         * user deletion.
43
+         */
44
+        try {
45
+            $uid = $event->getUser()->getUID();
46
+            $tokens = $this->manager->getTokenByUser($uid);
47
+            foreach ($tokens as $token) {
48
+                $this->manager->invalidateTokenById($uid, $token->getId());
49
+            }
50
+        } catch (Throwable $e) {
51
+            $this->logger->error('Could not clean up auth tokens after user deletion: ' . $e->getMessage(), [
52
+                'exception' => $e,
53
+            ]);
54
+        }
55
+    }
56 56
 }
Please login to merge, or discard this patch.
apps/settings/templates/settings/personal/security/twofactor.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@
 block discarded – undo
25 25
 ?>
26 26
 
27 27
 <div id="two-factor-auth" class="section">
28
-	<h2><?php p($l->t('Two-Factor Authentication'));?></h2>
28
+	<h2><?php p($l->t('Two-Factor Authentication')); ?></h2>
29 29
 	<a target="_blank" rel="noreferrer noopener" class="icon-info"
30
-	   title="<?php p($l->t('Open documentation'));?>"
30
+	   title="<?php p($l->t('Open documentation')); ?>"
31 31
 	   href="<?php p(link_to_docs('user-2fa')); ?>"></a>
32
-	<p class="settings-hint"><?php p($l->t('Use a second factor besides your password to increase security for your account.'));?></p>
33
-	<p class="settings-hint"><?php p($l->t('If you use third party applications to connect to Nextcloud, please make sure to create and configure an app password for each before enabling second factor authentication.'));?></p>
32
+	<p class="settings-hint"><?php p($l->t('Use a second factor besides your password to increase security for your account.')); ?></p>
33
+	<p class="settings-hint"><?php p($l->t('If you use third party applications to connect to Nextcloud, please make sure to create and configure an app password for each before enabling second factor authentication.')); ?></p>
34 34
 	<ul>
35 35
 	<?php foreach ($_['twoFactorProviderData']['providers'] as $data) { ?>
36 36
 		<li>
Please login to merge, or discard this patch.
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -19,18 +19,18 @@
 block discarded – undo
19 19
 		<li>
20 20
 			<?php
21 21
 
22
-			/** @var \OCP\Authentication\TwoFactorAuth\IProvidesPersonalSettings $provider */
23
-			$provider = $data['provider'];
24
-		//Handle 2FA provider icons and theme
25
-		if ($provider instanceof \OCP\Authentication\TwoFactorAuth\IProvidesIcons) {
26
-			$icon = $provider->getDarkIcon();
27
-			//fallback icon if the 2factor provider doesn't provide an icon.
28
-		} else {
29
-			$icon = image_path('core', 'actions/password.svg');
30
-		}
31
-		/** @var \OCP\Authentication\TwoFactorAuth\IPersonalProviderSettings $settings */
32
-		$settings = $data['settings'];
33
-		?>
22
+            /** @var \OCP\Authentication\TwoFactorAuth\IProvidesPersonalSettings $provider */
23
+            $provider = $data['provider'];
24
+        //Handle 2FA provider icons and theme
25
+        if ($provider instanceof \OCP\Authentication\TwoFactorAuth\IProvidesIcons) {
26
+            $icon = $provider->getDarkIcon();
27
+            //fallback icon if the 2factor provider doesn't provide an icon.
28
+        } else {
29
+            $icon = image_path('core', 'actions/password.svg');
30
+        }
31
+        /** @var \OCP\Authentication\TwoFactorAuth\IPersonalProviderSettings $settings */
32
+        $settings = $data['settings'];
33
+        ?>
34 34
 			<h3>
35 35
 				<img class="two-factor-provider-settings-icon" src="<?php p($icon) ?>" alt="">
36 36
 				<?php p($provider->getDisplayName()) ?>
Please login to merge, or discard this patch.