Completed
Push — php-cs-fixer ( b6f93e...b9836a )
by Fabio
07:15
created
framework/Security/TAuthorizationRuleCollection.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,10 +34,10 @@
 block discarded – undo
34 34
 	{
35 35
 		if($user instanceof IUser)
36 36
 		{
37
-			$verb = strtolower(trim($verb));
37
+			$verb=strtolower(trim($verb));
38 38
 			foreach($this as $rule)
39 39
 			{
40
-				if(($decision = $rule->isUserAllowed($user, $verb, $ip)) !== 0)
40
+				if(($decision=$rule->isUserAllowed($user, $verb, $ip))!==0)
41 41
 					return ($decision > 0);
42 42
 			}
43 43
 			return true;
Please login to merge, or discard this patch.
framework/Security/TUserManagerPasswordMode.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
  */
28 28
 class TUserManagerPasswordMode extends \Prado\TEnumerable
29 29
 {
30
-	const Clear = 'Clear';
31
-	const MD5 = 'MD5';
32
-	const SHA1 = 'SHA1';
30
+	const Clear='Clear';
31
+	const MD5='MD5';
32
+	const SHA1='SHA1';
33 33
 }
34 34
\ No newline at end of file
Please login to merge, or discard this patch.
framework/Security/TDbUser.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -37,19 +37,19 @@
 block discarded – undo
37 37
 	 */
38 38
 	public function getDbConnection()
39 39
 	{
40
-		if($this->_connection === null)
40
+		if($this->_connection===null)
41 41
 		{
42
-			$userManager = $this->getManager();
42
+			$userManager=$this->getManager();
43 43
 			if($userManager instanceof TDbUserManager)
44 44
 			{
45
-				$connection = $userManager->getDbConnection();
45
+				$connection=$userManager->getDbConnection();
46 46
 				if($connection instanceof TDbConnection)
47 47
 				{
48 48
 					$connection->setActive(true);
49
-					$this->_connection = $connection;
49
+					$this->_connection=$connection;
50 50
 				}
51 51
 			}
52
-			if($this->_connection === null)
52
+			if($this->_connection===null)
53 53
 				throw new TConfigurationException('dbuser_dbconnection_invalid');
54 54
 		}
55 55
 		return $this->_connection;
Please login to merge, or discard this patch.
framework/Security/TUserManager.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -75,28 +75,28 @@  discard block
 block discarded – undo
75 75
 	/**
76 76
 	 * extension name to the user file
77 77
 	 */
78
-	const USER_FILE_EXT = '.xml';
78
+	const USER_FILE_EXT='.xml';
79 79
 
80 80
 	/**
81 81
 	 * @var array list of users managed by this module
82 82
 	 */
83
-	private $_users = [];
83
+	private $_users=[];
84 84
 	/**
85 85
 	 * @var array list of roles managed by this module
86 86
 	 */
87
-	private $_roles = [];
87
+	private $_roles=[];
88 88
 	/**
89 89
 	 * @var string guest name
90 90
 	 */
91
-	private $_guestName = 'Guest';
91
+	private $_guestName='Guest';
92 92
 	/**
93 93
 	 * @var TUserManagerPasswordMode password mode
94 94
 	 */
95
-	private $_passwordMode = TUserManagerPasswordMode::MD5;
95
+	private $_passwordMode=TUserManagerPasswordMode::MD5;
96 96
 	/**
97 97
 	 * @var boolean whether the module has been initialized
98 98
 	 */
99
-	private $_initialized = false;
99
+	private $_initialized=false;
100 100
 	/**
101 101
 	 * @var string user/role information file
102 102
 	 */
@@ -111,21 +111,21 @@  discard block
 block discarded – undo
111 111
 	public function init($config)
112 112
 	{
113 113
 		$this->loadUserData($config);
114
-		if($this->_userFile !== null)
114
+		if($this->_userFile!==null)
115 115
 		{
116
-			if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
116
+			if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
117 117
 			{
118
-				$userFile = include $this->_userFile;
118
+				$userFile=include $this->_userFile;
119 119
 				$this->loadUserDataFromPhp($userFile);
120 120
 			}
121 121
 			else
122 122
 			{
123
-				$dom = new TXmlDocument;
123
+				$dom=new TXmlDocument;
124 124
 				$dom->loadFromFile($this->_userFile);
125 125
 				$this->loadUserDataFromXml($dom);
126 126
 			}
127 127
 		}
128
-		$this->_initialized = true;
128
+		$this->_initialized=true;
129 129
 	}
130 130
 
131 131
 	/*
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	private function loadUserData($config)
136 136
 	{
137
-		if($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
137
+		if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
138 138
 			$this->loadUserDataFromPhp($config);
139 139
 		else
140 140
 			$this->loadUserDataFromXml($config);
@@ -150,16 +150,16 @@  discard block
 block discarded – undo
150 150
 		{
151 151
 			foreach($config['users'] as $user)
152 152
 			{
153
-				$name = trim(strtolower(isset($user['name'])?$user['name']:''));
154
-				$password = isset($user['password'])?$user['password']:'';
155
-				$this->_users[$name] = $password;
156
-				$roles = isset($user['roles'])?$user['roles']:'';
157
-				if($roles !== '')
153
+				$name=trim(strtolower(isset($user['name']) ? $user['name'] : ''));
154
+				$password=isset($user['password']) ? $user['password'] : '';
155
+				$this->_users[$name]=$password;
156
+				$roles=isset($user['roles']) ? $user['roles'] : '';
157
+				if($roles!=='')
158 158
 				{
159 159
 					foreach(explode(',', $roles) as $role)
160 160
 					{
161
-						if(($role = trim($role)) !== '')
162
-							$this->_roles[$name][] = $role;
161
+						if(($role=trim($role))!=='')
162
+							$this->_roles[$name][]=$role;
163 163
 					}
164 164
 				}
165 165
 			}
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
 		{
169 169
 			foreach($config['roles'] as $role)
170 170
 			{
171
-				$name = isset($role['name'])?$role['name']:'';
172
-				$users = isset($role['users'])?$role['users']:'';
171
+				$name=isset($role['name']) ? $role['name'] : '';
172
+				$users=isset($role['users']) ? $role['users'] : '';
173 173
 				foreach(explode(',', $users) as $user)
174 174
 				{
175
-					if(($user = trim($user)) !== '')
176
-						$this->_roles[strtolower($user)][] = $name;
175
+					if(($user=trim($user))!=='')
176
+						$this->_roles[strtolower($user)][]=$name;
177 177
 				}
178 178
 			}
179 179
 		}
@@ -187,14 +187,14 @@  discard block
 block discarded – undo
187 187
 	{
188 188
 		foreach($xmlNode->getElementsByTagName('user') as $node)
189 189
 		{
190
-			$name = trim(strtolower($node->getAttribute('name')));
191
-			$this->_users[$name] = $node->getAttribute('password');
192
-			if(($roles = trim($node->getAttribute('roles'))) !== '')
190
+			$name=trim(strtolower($node->getAttribute('name')));
191
+			$this->_users[$name]=$node->getAttribute('password');
192
+			if(($roles=trim($node->getAttribute('roles')))!=='')
193 193
 			{
194 194
 				foreach(explode(',', $roles) as $role)
195 195
 				{
196
-					if(($role = trim($role)) !== '')
197
-						$this->_roles[$name][] = $role;
196
+					if(($role=trim($role))!=='')
197
+						$this->_roles[$name][]=$role;
198 198
 				}
199 199
 			}
200 200
 		}
@@ -202,8 +202,8 @@  discard block
 block discarded – undo
202 202
 		{
203 203
 			foreach(explode(',', $node->getAttribute('users')) as $user)
204 204
 			{
205
-				if(($user = trim($user)) !== '')
206
-					$this->_roles[strtolower($user)][] = $node->getAttribute('name');
205
+				if(($user=trim($user))!=='')
206
+					$this->_roles[strtolower($user)][]=$node->getAttribute('name');
207 207
 			}
208 208
 		}
209 209
 	}
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	{
251 251
 		if($this->_initialized)
252 252
 			throw new TInvalidOperationException('usermanager_userfile_unchangeable');
253
-		elseif(($this->_userFile = Prado::getPathOfNamespace($value, self::USER_FILE_EXT)) === null || !is_file($this->_userFile))
253
+		elseif(($this->_userFile=Prado::getPathOfNamespace($value, self::USER_FILE_EXT))===null || !is_file($this->_userFile))
254 254
 			throw new TConfigurationException('usermanager_userfile_invalid', $value);
255 255
 	}
256 256
 
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 	 */
268 268
 	public function setGuestName($value)
269 269
 	{
270
-		$this->_guestName = $value;
270
+		$this->_guestName=$value;
271 271
 	}
272 272
 
273 273
 	/**
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 	 */
284 284
 	public function setPasswordMode($value)
285 285
 	{
286
-		$this->_passwordMode = TPropertyValue::ensureEnum($value, 'Prado\\Security\\TUserManagerPasswordMode');
286
+		$this->_passwordMode=TPropertyValue::ensureEnum($value, 'Prado\\Security\\TUserManagerPasswordMode');
287 287
 	}
288 288
 
289 289
 	/**
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
 	 */
295 295
 	public function validateUser($username, $password)
296 296
 	{
297
-		if($this->_passwordMode === TUserManagerPasswordMode::MD5)
298
-			$password = md5($password);
299
-		elseif($this->_passwordMode === TUserManagerPasswordMode::SHA1)
300
-			$password = sha1($password);
301
-		$username = strtolower($username);
302
-		return (isset($this->_users[$username]) && $this->_users[$username] === $password);
297
+		if($this->_passwordMode===TUserManagerPasswordMode::MD5)
298
+			$password=md5($password);
299
+		elseif($this->_passwordMode===TUserManagerPasswordMode::SHA1)
300
+			$password=sha1($password);
301
+		$username=strtolower($username);
302
+		return (isset($this->_users[$username]) && $this->_users[$username]===$password);
303 303
 	}
304 304
 
305 305
 	/**
@@ -307,20 +307,20 @@  discard block
 block discarded – undo
307 307
 	 * @param string user name, null if it is a guest.
308 308
 	 * @return TUser the user instance, null if the specified username is not in the user database.
309 309
 	 */
310
-	public function getUser($username = null)
310
+	public function getUser($username=null)
311 311
 	{
312
-		if($username === null)
312
+		if($username===null)
313 313
 		{
314
-			$user = new TUser($this);
314
+			$user=new TUser($this);
315 315
 			$user->setIsGuest(true);
316 316
 			return $user;
317 317
 		}
318 318
 		else
319 319
 		{
320
-			$username = strtolower($username);
320
+			$username=strtolower($username);
321 321
 			if(isset($this->_users[$username]))
322 322
 			{
323
-				$user = new TUser($this);
323
+				$user=new TUser($this);
324 324
 				$user->setName($username);
325 325
 				$user->setIsGuest(false);
326 326
 				if(isset($this->_roles[$username]))
@@ -340,13 +340,13 @@  discard block
 block discarded – undo
340 340
 	 */
341 341
 	public function getUserFromCookie($cookie)
342 342
 	{
343
-		if(($data = $cookie->getValue()) !== '')
343
+		if(($data=$cookie->getValue())!=='')
344 344
 		{
345
-			$data = unserialize($data);
346
-			if(is_array($data) && count($data) === 2)
345
+			$data=unserialize($data);
346
+			if(is_array($data) && count($data)===2)
347 347
 			{
348
-				list($username, $token) = $data;
349
-				if(isset($this->_users[$username]) && $token === md5($username . $this->_users[$username]))
348
+				list($username, $token)=$data;
349
+				if(isset($this->_users[$username]) && $token===md5($username.$this->_users[$username]))
350 350
 					return $this->getUser($username);
351 351
 			}
352 352
 		}
@@ -360,11 +360,11 @@  discard block
 block discarded – undo
360 360
 	 */
361 361
 	public function saveUserToCookie($cookie)
362 362
 	{
363
-		$user = $this->getApplication()->getUser();
364
-		$username = strtolower($user->getName());
363
+		$user=$this->getApplication()->getUser();
364
+		$username=strtolower($user->getName());
365 365
 		if(isset($this->_users[$username]))
366 366
 		{
367
-			$data = [$username,md5($username . $this->_users[$username])];
367
+			$data=[$username, md5($username.$this->_users[$username])];
368 368
 			$cookie->setValue(serialize($data));
369 369
 		}
370 370
 	}
Please login to merge, or discard this patch.
framework/Security/TAuthManager.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
 	/**
48 48
 	 * GET variable name for return url
49 49
 	 */
50
-	const RETURN_URL_VAR = 'ReturnUrl';
50
+	const RETURN_URL_VAR='ReturnUrl';
51 51
 	/**
52 52
 	 * @var boolean if the module has been initialized
53 53
 	 */
54
-	private $_initialized = false;
54
+	private $_initialized=false;
55 55
 	/**
56 56
 	 * @var IUserManager user manager instance
57 57
 	 */
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	/**
64 64
 	 * @var boolean whether authorization should be skipped
65 65
 	 */
66
-	private $_skipAuthorization = false;
66
+	private $_skipAuthorization=false;
67 67
 	/**
68 68
 	 * @var string the session var name for storing return URL
69 69
 	 */
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	/**
72 72
 	 * @var boolean whether to allow auto login (using cookie)
73 73
 	 */
74
-	private $_allowAutoLogin = false;
74
+	private $_allowAutoLogin=false;
75 75
 	/**
76 76
 	 * @var string variable name used to store user session or cookie
77 77
 	 */
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	/**
80 80
 	 * @var integer authentication expiration time in seconds. Defaults to zero (no expiration)
81 81
 	 */
82
-	private $_authExpire = 0;
82
+	private $_authExpire=0;
83 83
 
84 84
 	/**
85 85
 	 * Initializes this module.
@@ -89,23 +89,23 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	public function init($config)
91 91
 	{
92
-		if($this->_userManager === null)
92
+		if($this->_userManager===null)
93 93
 			throw new TConfigurationException('authmanager_usermanager_required');
94
-		if($this->_returnUrlVarName === null)
95
-			$this->_returnUrlVarName = $this->getApplication()->getID() . ':' . self::RETURN_URL_VAR;
96
-		$application = $this->getApplication();
94
+		if($this->_returnUrlVarName===null)
95
+			$this->_returnUrlVarName=$this->getApplication()->getID().':'.self::RETURN_URL_VAR;
96
+		$application=$this->getApplication();
97 97
 		if(is_string($this->_userManager))
98 98
 		{
99
-			if(($users = $application->getModule($this->_userManager)) === null)
99
+			if(($users=$application->getModule($this->_userManager))===null)
100 100
 				throw new TConfigurationException('authmanager_usermanager_inexistent', $this->_userManager);
101 101
 			if(!($users instanceof IUserManager))
102 102
 				throw new TConfigurationException('authmanager_usermanager_invalid', $this->_userManager);
103
-			$this->_userManager = $users;
103
+			$this->_userManager=$users;
104 104
 		}
105
-		$application->attachEventHandler('OnAuthentication', [$this,'doAuthentication']);
106
-		$application->attachEventHandler('OnEndRequest', [$this,'leave']);
107
-		$application->attachEventHandler('OnAuthorization', [$this,'doAuthorization']);
108
-		$this->_initialized = true;
105
+		$application->attachEventHandler('OnAuthentication', [$this, 'doAuthentication']);
106
+		$application->attachEventHandler('OnEndRequest', [$this, 'leave']);
107
+		$application->attachEventHandler('OnAuthorization', [$this, 'doAuthorization']);
108
+		$this->_initialized=true;
109 109
 	}
110 110
 
111 111
 	/**
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 			throw new TInvalidOperationException('authmanager_usermanager_unchangeable');
127 127
 		if(!is_string($provider) && !($provider instanceof IUserManager))
128 128
 			throw new TConfigurationException('authmanager_usermanager_invalid', $this->_userManager);
129
-		$this->_userManager = $provider;
129
+		$this->_userManager=$provider;
130 130
 	}
131 131
 
132 132
 	/**
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 */
146 146
 	public function setLoginPage($pagePath)
147 147
 	{
148
-		$this->_loginPage = $pagePath;
148
+		$this->_loginPage=$pagePath;
149 149
 	}
150 150
 
151 151
 	/**
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
 	{
160 160
 		$this->onAuthenticate($param);
161 161
 
162
-		$service = $this->getService();
163
-		if(($service instanceof TPageService) && $service->getRequestedPagePath() === $this->getLoginPage())
164
-			$this->_skipAuthorization = true;
162
+		$service=$this->getService();
163
+		if(($service instanceof TPageService) && $service->getRequestedPagePath()===$this->getLoginPage())
164
+			$this->_skipAuthorization=true;
165 165
 	}
166 166
 
167 167
 	/**
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
 	 */
189 189
 	public function leave($sender, $param)
190 190
 	{
191
-		$application = $this->getApplication();
192
-		if($application->getResponse()->getStatusCode() === 401)
191
+		$application=$this->getApplication();
192
+		if($application->getResponse()->getStatusCode()===401)
193 193
 		{
194
-			$service = $application->getService();
194
+			$service=$application->getService();
195 195
 			if($service instanceof TPageService)
196 196
 			{
197
-				$returnUrl = $application->getRequest()->getRequestUri();
197
+				$returnUrl=$application->getRequest()->getRequestUri();
198 198
 				$this->setReturnUrl($returnUrl);
199
-				$url = $service->constructUrl($this->getLoginPage());
199
+				$url=$service->constructUrl($this->getLoginPage());
200 200
 				$application->getResponse()->redirect($url);
201 201
 			}
202 202
 		}
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 */
216 216
 	public function setReturnUrlVarName($value)
217 217
 	{
218
-		$this->_returnUrlVarName = $value;
218
+		$this->_returnUrlVarName=$value;
219 219
 	}
220 220
 
221 221
 	/**
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	 */
251 251
 	public function setAllowAutoLogin($value)
252 252
 	{
253
-		$this->_allowAutoLogin = TPropertyValue::ensureBoolean($value);
253
+		$this->_allowAutoLogin=TPropertyValue::ensureBoolean($value);
254 254
 	}
255 255
 
256 256
 	/**
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 	 */
269 269
 	public function setAuthExpire($value)
270 270
 	{
271
-		$this->_authExpire = TPropertyValue::ensureInteger($value);
271
+		$this->_authExpire=TPropertyValue::ensureInteger($value);
272 272
 	}
273 273
 
274 274
 	/**
@@ -281,31 +281,31 @@  discard block
 block discarded – undo
281 281
 	 */
282 282
 	public function onAuthenticate($param)
283 283
 	{
284
-		$application = $this->getApplication();
284
+		$application=$this->getApplication();
285 285
 
286 286
 		// restoring user info from session
287
-		if(($session = $application->getSession()) === null)
287
+		if(($session=$application->getSession())===null)
288 288
 			throw new TConfigurationException('authmanager_session_required');
289 289
 		$session->open();
290
-		$sessionInfo = $session->itemAt($this->getUserKey());
291
-		$user = $this->_userManager->getUser(null)->loadFromString($sessionInfo);
290
+		$sessionInfo=$session->itemAt($this->getUserKey());
291
+		$user=$this->_userManager->getUser(null)->loadFromString($sessionInfo);
292 292
 
293 293
 		// check for authentication expiration
294
-		$isAuthExpired = $this->_authExpire > 0 && !$user->getIsGuest() &&
295
-		($expiretime = $session->itemAt('AuthExpireTime')) && $expiretime < time();
294
+		$isAuthExpired=$this->_authExpire > 0 && !$user->getIsGuest() &&
295
+		($expiretime=$session->itemAt('AuthExpireTime')) && $expiretime < time();
296 296
 
297 297
 		// try authenticating through cookie if possible
298 298
 		if($this->getAllowAutoLogin() && ($user->getIsGuest() || $isAuthExpired))
299 299
 		{
300
-			$cookie = $this->getRequest()->getCookies()->itemAt($this->getUserKey());
300
+			$cookie=$this->getRequest()->getCookies()->itemAt($this->getUserKey());
301 301
 			if($cookie instanceof THttpCookie)
302 302
 			{
303
-				if(($user2 = $this->_userManager->getUserFromCookie($cookie)) !== null)
303
+				if(($user2=$this->_userManager->getUserFromCookie($cookie))!==null)
304 304
 				{
305
-					$user = $user2;
305
+					$user=$user2;
306 306
 					$this->updateSessionUser($user);
307 307
 					// user is restored from cookie, auth may not expire
308
-					$isAuthExpired = false;
308
+					$isAuthExpired=false;
309 309
 				}
310 310
 			}
311 311
 		}
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 	 */
345 345
 	public function onAuthorize($param)
346 346
 	{
347
-		$application = $this->getApplication();
347
+		$application=$this->getApplication();
348 348
 		if($this->hasEventHandler('OnAuthorize'))
349 349
 			$this->raiseEvent('OnAuthorize', $this, $application);
350 350
 		if(!$application->getAuthorizationRules()->isUserAllowed($application->getUser(), $application->getRequest()->getRequestType(), $application->getRequest()->getUserHostAddress()))
@@ -360,8 +360,8 @@  discard block
 block discarded – undo
360 360
 	 */
361 361
 	public function getUserKey()
362 362
 	{
363
-		if($this->_userKey === null)
364
-			$this->_userKey = $this->generateUserKey();
363
+		if($this->_userKey===null)
364
+			$this->_userKey=$this->generateUserKey();
365 365
 		return $this->_userKey;
366 366
 	}
367 367
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	 */
372 372
 	protected function generateUserKey()
373 373
 	{
374
-		return md5($this->getApplication()->getUniqueID() . 'prado:user');
374
+		return md5($this->getApplication()->getUniqueID().'prado:user');
375 375
 	}
376 376
 
377 377
 	/**
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 	{
384 384
 		if(!$user->getIsGuest())
385 385
 		{
386
-			if(($session = $this->getSession()) === null)
386
+			if(($session=$this->getSession())===null)
387 387
 				throw new TConfigurationException('authmanager_session_required');
388 388
 			else
389 389
 				$session->add($this->getUserKey(), $user->saveToString());
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 	 */
399 399
 	public function switchUser($username)
400 400
 	{
401
-		if(($user = $this->_userManager->getUser($username)) === null)
401
+		if(($user=$this->_userManager->getUser($username))===null)
402 402
 			return false;
403 403
 		$this->updateSessionUser($user);
404 404
 		$this->getApplication()->setUser($user);
@@ -414,18 +414,18 @@  discard block
 block discarded – undo
414 414
 	 * @param integer number of seconds that automatic login will remain effective. If 0, it means user logs out when session ends. This parameter is added since 3.1.1.
415 415
 	 * @return boolean if login is successful
416 416
 	 */
417
-	public function login($username, $password, $expire = 0)
417
+	public function login($username, $password, $expire=0)
418 418
 	{
419 419
 		if($this->_userManager->validateUser($username, $password))
420 420
 		{
421
-			if(($user = $this->_userManager->getUser($username)) === null)
421
+			if(($user=$this->_userManager->getUser($username))===null)
422 422
 				return false;
423 423
 			$this->updateSessionUser($user);
424 424
 			$this->getApplication()->setUser($user);
425 425
 
426 426
 			if($expire > 0)
427 427
 			{
428
-				$cookie = new THttpCookie($this->getUserKey(), '');
428
+				$cookie=new THttpCookie($this->getUserKey(), '');
429 429
 				$cookie->setExpire(time() + $expire);
430 430
 				$this->_userManager->saveUserToCookie($cookie);
431 431
 				$this->getResponse()->getCookies()->add($cookie);
@@ -443,13 +443,13 @@  discard block
 block discarded – undo
443 443
 	 */
444 444
 	public function logout()
445 445
 	{
446
-		if(($session = $this->getSession()) === null)
446
+		if(($session=$this->getSession())===null)
447 447
 			throw new TConfigurationException('authmanager_session_required');
448 448
 		$this->getApplication()->getUser()->setIsGuest(true);
449 449
 		$session->destroy();
450 450
 		if($this->getAllowAutoLogin())
451 451
 		{
452
-			$cookie = new THttpCookie($this->getUserKey(), '');
452
+			$cookie=new THttpCookie($this->getUserKey(), '');
453 453
 			$this->getResponse()->getCookies()->add($cookie);
454 454
 		}
455 455
 	}
Please login to merge, or discard this patch.
framework/Security/TUser.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	/**
38 38
 	 * @var boolean whether user state is changed
39 39
 	 */
40
-	private $_stateChanged = false;
40
+	private $_stateChanged=false;
41 41
 	/**
42 42
 	 * @var IUserManager user manager
43 43
 	 */
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	public function __construct(IUserManager $manager)
51 51
 	{
52
-		$this->_state = [];
53
-		$this->_manager = $manager;
52
+		$this->_state=[];
53
+		$this->_manager=$manager;
54 54
 		$this->setName($manager->getGuestName());
55 55
 	}
56 56
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public function setIsGuest($value)
93 93
 	{
94
-		if($isGuest = TPropertyValue::ensureBoolean($value))
94
+		if($isGuest=TPropertyValue::ensureBoolean($value))
95 95
 		{
96 96
 			$this->setName($this->_manager->getGuestName());
97 97
 			$this->setRoles([]);
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 			$this->setState('Roles', $value, []);
117 117
 		else
118 118
 		{
119
-			$roles = [];
119
+			$roles=[];
120 120
 			foreach(explode(',', $value) as $role)
121 121
 			{
122
-				if(($role = trim($role)) !== '')
123
-					$roles[] = $role;
122
+				if(($role=trim($role))!=='')
123
+					$roles[]=$role;
124 124
 			}
125 125
 			$this->setState('Roles', $roles, []);
126 126
 		}
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	public function isInRole($role)
134 134
 	{
135 135
 		foreach($this->getRoles() as $r)
136
-			if(strcasecmp($role, $r) === 0)
136
+			if(strcasecmp($role, $r)===0)
137 137
 				return true;
138 138
 		return false;
139 139
 	}
@@ -153,9 +153,9 @@  discard block
 block discarded – undo
153 153
 	public function loadFromString($data)
154 154
 	{
155 155
 		if(!empty($data))
156
-			$this->_state = unserialize($data);
156
+			$this->_state=unserialize($data);
157 157
 		if(!is_array($this->_state))
158
-			$this->_state = [];
158
+			$this->_state=[];
159 159
 		return $this;
160 160
 	}
161 161
 
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
 	 * @return mixed the value of the variable. If it doesn't exist, the provided default value will be returned
173 173
 	 * @see setState
174 174
 	 */
175
-	protected function getState($key, $defaultValue = null)
175
+	protected function getState($key, $defaultValue=null)
176 176
 	{
177
-		return isset($this->_state[$key])?$this->_state[$key]:$defaultValue;
177
+		return isset($this->_state[$key]) ? $this->_state[$key] : $defaultValue;
178 178
 	}
179 179
 
180 180
 	/**
@@ -191,13 +191,13 @@  discard block
 block discarded – undo
191 191
 	 * @param mixed default value. If $value===$defaultValue, the variable will be removed from persistent storage.
192 192
 	 * @see getState
193 193
 	 */
194
-	protected function setState($key, $value, $defaultValue = null)
194
+	protected function setState($key, $value, $defaultValue=null)
195 195
 	{
196
-		if($value === $defaultValue)
196
+		if($value===$defaultValue)
197 197
 			unset($this->_state[$key]);
198 198
 		else
199
-			$this->_state[$key] = $value;
200
-		$this->_stateChanged = true;
199
+			$this->_state[$key]=$value;
200
+		$this->_stateChanged=true;
201 201
 	}
202 202
 
203 203
 	/**
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 	 */
214 214
 	public function setStateChanged($value)
215 215
 	{
216
-		$this->_stateChanged = TPropertyValue::ensureBoolean($value);
216
+		$this->_stateChanged=TPropertyValue::ensureBoolean($value);
217 217
 	}
218 218
 }
219 219
 
Please login to merge, or discard this patch.
framework/Security/TDbUserManager.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
  */
49 49
 class TDbUserManager extends \Prado\TModule implements IUserManager
50 50
 {
51
-	private $_connID = '';
51
+	private $_connID='';
52 52
 	private $_conn;
53
-	private $_guestName = 'Guest';
54
-	private $_userClass = '';
53
+	private $_guestName='Guest';
54
+	private $_userClass='';
55 55
 	private $_userFactory;
56 56
 
57 57
 	/**
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	public function init($config)
63 63
 	{
64
-		if($this->_userClass === '')
64
+		if($this->_userClass==='')
65 65
 			throw new TConfigurationException('dbusermanager_userclass_required');
66
-		$this->_userFactory = Prado::createComponent($this->_userClass, $this);
66
+		$this->_userFactory=Prado::createComponent($this->_userClass, $this);
67 67
 		if(!($this->_userFactory instanceof TDbUser))
68 68
 			throw new TInvalidDataTypeException('dbusermanager_userclass_invalid', $this->_userClass);
69 69
 	}
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	public function setUserClass($value)
83 83
 	{
84
-		$this->_userClass = $value;
84
+		$this->_userClass=$value;
85 85
 	}
86 86
 
87 87
 	/**
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function setGuestName($value)
99 99
 	{
100
-		$this->_guestName = $value;
100
+		$this->_guestName=$value;
101 101
 	}
102 102
 
103 103
 	/**
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 	 * @param string user name, null if it is a guest.
117 117
 	 * @return TUser the user instance, null if the specified username is not in the user database.
118 118
 	 */
119
-	public function getUser($username = null)
119
+	public function getUser($username=null)
120 120
 	{
121
-		if($username === null)
121
+		if($username===null)
122 122
 		{
123
-			$user = Prado::createComponent($this->_userClass, $this);
123
+			$user=Prado::createComponent($this->_userClass, $this);
124 124
 			$user->setIsGuest(true);
125 125
 			return $user;
126 126
 		}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 */
145 145
 	public function setConnectionID($value)
146 146
 	{
147
-		$this->_connID = $value;
147
+		$this->_connID=$value;
148 148
 	}
149 149
 
150 150
 	/**
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	public function getDbConnection()
154 154
 	{
155
-		if($this->_conn === null)
155
+		if($this->_conn===null)
156 156
 		{
157
-			$this->_conn = $this->createDbConnection($this->_connID);
157
+			$this->_conn=$this->createDbConnection($this->_connID);
158 158
 			$this->_conn->setActive(true);
159 159
 		}
160 160
 		return $this->_conn;
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
 	 */
169 169
 	protected function createDbConnection($connectionID)
170 170
 	{
171
-		if($connectionID !== '')
171
+		if($connectionID!=='')
172 172
 		{
173
-			$conn = $this->getApplication()->getModule($connectionID);
173
+			$conn=$this->getApplication()->getModule($connectionID);
174 174
 			if($conn instanceof TDataSourceConfig)
175 175
 				return $conn->getDbConnection();
176 176
 			else
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 */
199 199
 	public function saveUserToCookie($cookie)
200 200
 	{
201
-		$user = $this->getApplication()->getUser();
201
+		$user=$this->getApplication()->getUser();
202 202
 		if($user instanceof TDbUser)
203 203
 			$user->saveUserToCookie($cookie);
204 204
 	}
Please login to merge, or discard this patch.
framework/Security/TSecurityManager.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
  */
51 51
 class TSecurityManager extends \Prado\TModule
52 52
 {
53
-	const STATE_VALIDATION_KEY = 'prado:securitymanager:validationkey';
54
-	const STATE_ENCRYPTION_KEY = 'prado:securitymanager:encryptionkey';
53
+	const STATE_VALIDATION_KEY='prado:securitymanager:validationkey';
54
+	const STATE_ENCRYPTION_KEY='prado:securitymanager:encryptionkey';
55 55
 
56 56
 	private $_validationKey;
57 57
 	private $_encryptionKey;
58
-	private $_hashAlgorithm = 'sha256';
59
-	private $_cryptAlgorithm = 'aes-256-cbc';
58
+	private $_hashAlgorithm='sha256';
59
+	private $_cryptAlgorithm='aes-256-cbc';
60 60
 	private $_mbstring;
61 61
 
62 62
 	/**
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function init($config)
68 68
 	{
69
-		$this->_mbstring = extension_loaded('mbstring');
69
+		$this->_mbstring=extension_loaded('mbstring');
70 70
 		$this->getApplication()->setSecurityManager($this);
71 71
 	}
72 72
 
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	public function getValidationKey()
86 86
 	{
87
-		if(null === $this->_validationKey) {
88
-			if(null === ($this->_validationKey = $this->getApplication()->getGlobalState(self::STATE_VALIDATION_KEY))) {
89
-				$this->_validationKey = $this->generateRandomKey();
87
+		if(null===$this->_validationKey) {
88
+			if(null===($this->_validationKey=$this->getApplication()->getGlobalState(self::STATE_VALIDATION_KEY))) {
89
+				$this->_validationKey=$this->generateRandomKey();
90 90
 				$this->getApplication()->setGlobalState(self::STATE_VALIDATION_KEY, $this->_validationKey, null, true);
91 91
 			}
92 92
 		}
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	public function setValidationKey($value)
101 101
 	{
102
-		if('' === $value)
102
+		if(''===$value)
103 103
 			throw new TInvalidDataValueException('securitymanager_validationkey_invalid');
104 104
 
105
-		$this->_validationKey = $value;
105
+		$this->_validationKey=$value;
106 106
 	}
107 107
 
108 108
 	/**
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	public function getEncryptionKey()
113 113
 	{
114
-		if(null === $this->_encryptionKey) {
115
-			if(null === ($this->_encryptionKey = $this->getApplication()->getGlobalState(self::STATE_ENCRYPTION_KEY))) {
116
-				$this->_encryptionKey = $this->generateRandomKey();
114
+		if(null===$this->_encryptionKey) {
115
+			if(null===($this->_encryptionKey=$this->getApplication()->getGlobalState(self::STATE_ENCRYPTION_KEY))) {
116
+				$this->_encryptionKey=$this->generateRandomKey();
117 117
 				$this->getApplication()->setGlobalState(self::STATE_ENCRYPTION_KEY, $this->_encryptionKey, null, true);
118 118
 			}
119 119
 		}
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	public function setEncryptionKey($value)
128 128
 	{
129
-		if('' === $value)
129
+		if(''===$value)
130 130
 			throw new TInvalidDataValueException('securitymanager_encryptionkey_invalid');
131 131
 
132
-		$this->_encryptionKey = $value;
132
+		$this->_encryptionKey=$value;
133 133
 	}
134 134
 
135 135
 	/**
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	public function setHashAlgorithm($value)
149 149
 	{
150
-		$this->_hashAlgorithm = TPropertyValue::ensureString($value);
150
+		$this->_hashAlgorithm=TPropertyValue::ensureString($value);
151 151
 		if(!in_array($this->_hashAlgorithm, hash_algos()))
152 152
 			throw new TInvalidDataValueException('securitymanager_hash_algorithm_invalid');
153 153
 	}
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 */
167 167
 	public function setCryptAlgorithm($value)
168 168
 	{
169
-		$this->_cryptAlgorithm = TPropertyValue::ensureString($value);
169
+		$this->_cryptAlgorithm=TPropertyValue::ensureString($value);
170 170
 		if(!in_array($this->_hashAlgorithm, openssl_get_cipher_methods()))
171 171
 			throw new TInvalidDataValueException('securitymanager_crypt_algorithm_invalid');
172 172
 	}
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
 	{
182 182
 		if(extension_loaded('openssl'))
183 183
 		{
184
-			$key = md5($this->getEncryptionKey());
185
-			$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($this->_cryptAlgorithm));
186
-			return $iv . openssl_encrypt($data, $this->_cryptAlgorithm, $key, null, $iv);
184
+			$key=md5($this->getEncryptionKey());
185
+			$iv=openssl_random_pseudo_bytes(openssl_cipher_iv_length($this->_cryptAlgorithm));
186
+			return $iv.openssl_encrypt($data, $this->_cryptAlgorithm, $key, null, $iv);
187 187
 		}
188 188
 		else
189 189
 			throw new TNotSupportedException('securitymanager_openssl_required');
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
 	{
200 200
 		if(extension_loaded('openssl'))
201 201
 		{
202
-			$key = md5($this->getEncryptionKey());
203
-			$iv = $this->substr($data, 0, openssl_cipher_iv_length($this->_cryptAlgorithm));
202
+			$key=md5($this->getEncryptionKey());
203
+			$iv=$this->substr($data, 0, openssl_cipher_iv_length($this->_cryptAlgorithm));
204 204
 			return openssl_decrypt($this->substr($data, $this->strlen($iv), $this->strlen($data)), $this->_cryptAlgorithm, $key, null, $iv);
205 205
 		}
206 206
 		else
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	public function hashData($data)
216 216
 	{
217
-		$hmac = $this->computeHMAC($data);
218
-		return $hmac . $data;
217
+		$hmac=$this->computeHMAC($data);
218
+		return $hmac.$data;
219 219
 	}
220 220
 
221 221
 	/**
@@ -227,14 +227,14 @@  discard block
 block discarded – undo
227 227
 	 */
228 228
 	public function validateData($data)
229 229
 	{
230
-		$len = $this->strlen($this->computeHMAC('test'));
230
+		$len=$this->strlen($this->computeHMAC('test'));
231 231
 
232 232
 		if($this->strlen($data) < $len)
233 233
 			return false;
234 234
 
235
-		$hmac = $this->substr($data, 0, $len);
236
-		$data2 = $this->substr($data, $len, $this->strlen($data));
237
-		return $hmac === $this->computeHMAC($data2) ? $data2 : false;
235
+		$hmac=$this->substr($data, 0, $len);
236
+		$data2=$this->substr($data, $len, $this->strlen($data));
237
+		return $hmac===$this->computeHMAC($data2) ? $data2 : false;
238 238
 	}
239 239
 
240 240
 	/**
Please login to merge, or discard this patch.
framework/Security/IUserManager.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 	 * @param string user name, null if it is a guest.
34 34
 	 * @return TUser the user instance, null if the specified username is not in the user database.
35 35
 	 */
36
-	public function getUser($username = null);
36
+	public function getUser($username=null);
37 37
 	/**
38 38
 	 * Returns a user instance according to auth data stored in a cookie.
39 39
 	 * @param THttpCookie the cookie storing user authentication information
Please login to merge, or discard this patch.