aboutsummaryrefslogtreecommitdiffhomepage
path: root/main/app/sprinkles/account/src
diff options
context:
space:
mode:
authorMarvin Borner2018-05-23 22:23:28 +0200
committerMarvin Borner2018-05-23 22:23:28 +0200
commitb66a61addb6c8e66cb26fcf74b532d68891267e4 (patch)
tree05e9449ff25bdc98f68105f41923ccb9f6ef5095 /main/app/sprinkles/account/src
parent1d4ef435177a5f9b6d1a289800d933e49be0c550 (diff)
Refactored code, many fixes and improvements in chat backend+frontend
Diffstat (limited to 'main/app/sprinkles/account/src')
-rw-r--r--main/app/sprinkles/account/src/Account.php1
-rw-r--r--main/app/sprinkles/account/src/Authenticate/AuthGuard.php13
-rw-r--r--main/app/sprinkles/account/src/Authenticate/Exception/AccountDisabledException.php1
-rw-r--r--main/app/sprinkles/account/src/Authenticate/Exception/AccountInvalidException.php1
-rw-r--r--main/app/sprinkles/account/src/Authenticate/Exception/AccountNotVerifiedException.php1
-rw-r--r--main/app/sprinkles/account/src/Authenticate/Exception/AuthCompromisedException.php1
-rw-r--r--main/app/sprinkles/account/src/Authenticate/Exception/AuthExpiredException.php1
-rw-r--r--main/app/sprinkles/account/src/Authenticate/Exception/InvalidCredentialsException.php1
-rw-r--r--main/app/sprinkles/account/src/Authenticate/Hasher.php29
-rw-r--r--main/app/sprinkles/account/src/Authorize/AccessConditionExpression.php23
-rw-r--r--main/app/sprinkles/account/src/Authorize/AuthorizationException.php1
-rw-r--r--main/app/sprinkles/account/src/Authorize/AuthorizationManager.php30
-rw-r--r--main/app/sprinkles/account/src/Authorize/ParserNodeFunctionEvaluator.php40
-rw-r--r--main/app/sprinkles/account/src/Bakery/CreateAdminUser.php77
-rw-r--r--main/app/sprinkles/account/src/Controller/AccountController.php154
-rw-r--r--main/app/sprinkles/account/src/Controller/Exception/SpammyRequestException.php1
-rw-r--r--main/app/sprinkles/account/src/Database/Migrations/v400/ActivitiesTable.php7
-rw-r--r--main/app/sprinkles/account/src/Database/Migrations/v400/GroupsTable.php11
-rw-r--r--main/app/sprinkles/account/src/Database/Migrations/v400/PasswordResetsTable.php7
-rw-r--r--main/app/sprinkles/account/src/Database/Migrations/v400/PermissionRolesTable.php7
-rw-r--r--main/app/sprinkles/account/src/Database/Migrations/v400/PermissionsTable.php12
-rw-r--r--main/app/sprinkles/account/src/Database/Migrations/v400/PersistencesTable.php7
-rw-r--r--main/app/sprinkles/account/src/Database/Migrations/v400/RoleUsersTable.php7
-rw-r--r--main/app/sprinkles/account/src/Database/Migrations/v400/RolesTable.php7
-rw-r--r--main/app/sprinkles/account/src/Database/Migrations/v400/UsersTable.php7
-rw-r--r--main/app/sprinkles/account/src/Database/Migrations/v400/VerificationsTable.php7
-rw-r--r--main/app/sprinkles/account/src/Database/Models/Activity.php13
-rw-r--r--main/app/sprinkles/account/src/Database/Models/Group.php9
-rw-r--r--main/app/sprinkles/account/src/Database/Models/PasswordReset.php12
-rw-r--r--main/app/sprinkles/account/src/Database/Models/Permission.php22
-rw-r--r--main/app/sprinkles/account/src/Database/Models/Role.php22
-rw-r--r--main/app/sprinkles/account/src/Database/Models/Verification.php12
-rw-r--r--main/app/sprinkles/account/src/Error/Handler/AuthCompromisedExceptionHandler.php4
-rw-r--r--main/app/sprinkles/account/src/Error/Handler/AuthExpiredExceptionHandler.php8
-rw-r--r--main/app/sprinkles/account/src/Error/Handler/ForbiddenExceptionHandler.php4
-rw-r--r--main/app/sprinkles/account/src/Facades/Password.php4
-rw-r--r--main/app/sprinkles/account/src/Log/UserActivityDatabaseHandler.php4
-rw-r--r--main/app/sprinkles/account/src/Log/UserActivityProcessor.php11
-rw-r--r--main/app/sprinkles/account/src/Repository/PasswordResetRepository.php4
-rw-r--r--main/app/sprinkles/account/src/Repository/TokenRepository.php57
-rw-r--r--main/app/sprinkles/account/src/Repository/VerificationRepository.php4
-rw-r--r--main/app/sprinkles/account/src/ServicesProvider/ServicesProvider.php32
-rw-r--r--main/app/sprinkles/account/src/Twig/AccountExtension.php17
-rw-r--r--main/app/sprinkles/account/src/Util/HashFailedException.php1
-rw-r--r--main/app/sprinkles/account/src/Util/Util.php4
45 files changed, 312 insertions, 386 deletions
diff --git a/main/app/sprinkles/account/src/Account.php b/main/app/sprinkles/account/src/Account.php
index 49c2de9..9f43166 100644
--- a/main/app/sprinkles/account/src/Account.php
+++ b/main/app/sprinkles/account/src/Account.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account;
use UserFrosting\System\Sprinkle\Sprinkle;
diff --git a/main/app/sprinkles/account/src/Authenticate/AuthGuard.php b/main/app/sprinkles/account/src/Authenticate/AuthGuard.php
index efcfaae..ce64bd7 100644
--- a/main/app/sprinkles/account/src/Authenticate/AuthGuard.php
+++ b/main/app/sprinkles/account/src/Authenticate/AuthGuard.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Authenticate;
use Psr\Http\Message\ResponseInterface;
@@ -29,22 +30,20 @@ class AuthGuard
*
* @param $authenticator Authenticator The current authentication object.
*/
- public function __construct($authenticator)
- {
+ public function __construct($authenticator) {
$this->authenticator = $authenticator;
}
/**
* Invoke the AuthGuard middleware, throwing an exception if there is no authenticated user in the session.
*
- * @param \Psr\Http\Message\ServerRequestInterface $request PSR7 request
- * @param \Psr\Http\Message\ResponseInterface $response PSR7 response
- * @param callable $next Next middleware
+ * @param \Psr\Http\Message\ServerRequestInterface $request PSR7 request
+ * @param \Psr\Http\Message\ResponseInterface $response PSR7 response
+ * @param callable $next Next middleware
*
* @return \Psr\Http\Message\ResponseInterface
*/
- public function __invoke($request, $response, $next)
- {
+ public function __invoke($request, $response, $next) {
if (!$this->authenticator->check()) {
throw new AuthExpiredException();
} else {
diff --git a/main/app/sprinkles/account/src/Authenticate/Exception/AccountDisabledException.php b/main/app/sprinkles/account/src/Authenticate/Exception/AccountDisabledException.php
index e79ceb5..3ad4c59 100644
--- a/main/app/sprinkles/account/src/Authenticate/Exception/AccountDisabledException.php
+++ b/main/app/sprinkles/account/src/Authenticate/Exception/AccountDisabledException.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Authenticate\Exception;
use UserFrosting\Support\Exception\HttpException;
diff --git a/main/app/sprinkles/account/src/Authenticate/Exception/AccountInvalidException.php b/main/app/sprinkles/account/src/Authenticate/Exception/AccountInvalidException.php
index 607235b..fb06fae 100644
--- a/main/app/sprinkles/account/src/Authenticate/Exception/AccountInvalidException.php
+++ b/main/app/sprinkles/account/src/Authenticate/Exception/AccountInvalidException.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Authenticate\Exception;
use UserFrosting\Support\Exception\HttpException;
diff --git a/main/app/sprinkles/account/src/Authenticate/Exception/AccountNotVerifiedException.php b/main/app/sprinkles/account/src/Authenticate/Exception/AccountNotVerifiedException.php
index 7eb56a6..2a721bb 100644
--- a/main/app/sprinkles/account/src/Authenticate/Exception/AccountNotVerifiedException.php
+++ b/main/app/sprinkles/account/src/Authenticate/Exception/AccountNotVerifiedException.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Authenticate\Exception;
use UserFrosting\Support\Exception\HttpException;
diff --git a/main/app/sprinkles/account/src/Authenticate/Exception/AuthCompromisedException.php b/main/app/sprinkles/account/src/Authenticate/Exception/AuthCompromisedException.php
index df3efbe..52fd528 100644
--- a/main/app/sprinkles/account/src/Authenticate/Exception/AuthCompromisedException.php
+++ b/main/app/sprinkles/account/src/Authenticate/Exception/AuthCompromisedException.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Authenticate\Exception;
use UserFrosting\Support\Exception\ForbiddenException;
diff --git a/main/app/sprinkles/account/src/Authenticate/Exception/AuthExpiredException.php b/main/app/sprinkles/account/src/Authenticate/Exception/AuthExpiredException.php
index 5583746..ab7cbdb 100644
--- a/main/app/sprinkles/account/src/Authenticate/Exception/AuthExpiredException.php
+++ b/main/app/sprinkles/account/src/Authenticate/Exception/AuthExpiredException.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Authenticate\Exception;
use UserFrosting\Support\Exception\HttpException;
diff --git a/main/app/sprinkles/account/src/Authenticate/Exception/InvalidCredentialsException.php b/main/app/sprinkles/account/src/Authenticate/Exception/InvalidCredentialsException.php
index 18d4a5c..78ea3de 100644
--- a/main/app/sprinkles/account/src/Authenticate/Exception/InvalidCredentialsException.php
+++ b/main/app/sprinkles/account/src/Authenticate/Exception/InvalidCredentialsException.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Authenticate\Exception;
use UserFrosting\Support\Exception\HttpException;
diff --git a/main/app/sprinkles/account/src/Authenticate/Hasher.php b/main/app/sprinkles/account/src/Authenticate/Hasher.php
index e277eef..5de939f 100644
--- a/main/app/sprinkles/account/src/Authenticate/Hasher.php
+++ b/main/app/sprinkles/account/src/Authenticate/Hasher.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Authenticate;
/**
@@ -28,12 +29,11 @@ class Hasher
* @param string $password the hashed password.
* @return string "sha1"|"legacy"|"modern".
*/
- public function getHashType($password)
- {
+ public function getHashType($password) {
// If the password in the db is 65 characters long, we have an sha1-hashed password.
if (strlen($password) == 65) {
return 'sha1';
- } elseif (strlen($password) == 82) {
+ } else if (strlen($password) == 82) {
return 'legacy';
}
@@ -44,12 +44,11 @@ class Hasher
* Hashes a plaintext password using bcrypt.
*
* @param string $password the plaintext password.
- * @param array $options
+ * @param array $options
* @return string the hashed password.
* @throws HashFailedException
*/
- public function hash($password, array $options = [])
- {
+ public function hash($password, array $options = []) {
$hash = password_hash($password, PASSWORD_BCRYPT, [
'cost' => $this->cost($options),
]);
@@ -66,21 +65,20 @@ class Hasher
*
* @param string $password The plaintext password to verify.
* @param string $hash The hash to compare against.
- * @param array $options
+ * @param array $options
* @return boolean True if the password matches, false otherwise.
*/
- public function verify($password, $hash, array $options = [])
- {
+ public function verify($password, $hash, array $options = []) {
$hashType = $this->getHashType($hash);
if ($hashType == 'sha1') {
// Legacy UserCake passwords
- $salt = substr($hash, 0, 25); // Extract the salt from the hash
+ $salt = substr($hash, 0, 25); // Extract the salt from the hash
$inputHash = $salt . sha1($salt . $password);
- return (hash_equals($inputHash, $hash) === true);
+ return (hash_equals($inputHash, $hash) === TRUE);
- } elseif ($hashType == 'legacy') {
+ } else if ($hashType == 'legacy') {
// Homegrown implementation (assuming that current install has been using a cost parameter of 12)
// Used for manual implementation of bcrypt.
// Note that this legacy hashing put the salt at the _end_ for some reason.
@@ -88,7 +86,7 @@ class Hasher
$inputHash = crypt($password, '$2y$12$' . $salt);
$correctHash = substr($hash, 0, 60);
- return (hash_equals($inputHash, $correctHash) === true);
+ return (hash_equals($inputHash, $correctHash) === TRUE);
}
// Modern implementation
@@ -98,11 +96,10 @@ class Hasher
/**
* Extract the cost value from the options array.
*
- * @param array $options
+ * @param array $options
* @return int
*/
- protected function cost(array $options = [])
- {
+ protected function cost(array $options = []) {
return isset($options['rounds']) ? $options['rounds'] : $this->defaultRounds;
}
}
diff --git a/main/app/sprinkles/account/src/Authorize/AccessConditionExpression.php b/main/app/sprinkles/account/src/Authorize/AccessConditionExpression.php
index dd5647e..e36f4f4 100644
--- a/main/app/sprinkles/account/src/Authorize/AccessConditionExpression.php
+++ b/main/app/sprinkles/account/src/Authorize/AccessConditionExpression.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Authorize;
use Monolog\Logger;
@@ -69,15 +70,14 @@ class AccessConditionExpression
* @param Logger $logger A Monolog logger, used to dump debugging info for authorization evaluations.
* @param bool $debug Set to true if you want debugging information printed to the auth log.
*/
- public function __construct(ParserNodeFunctionEvaluator $nodeVisitor, User $user, Logger $logger, $debug = false)
- {
- $this->nodeVisitor = $nodeVisitor;
- $this->user = $user;
- $this->parser = new Parser(new EmulativeLexer);
- $this->traverser = new NodeTraverser;
+ public function __construct(ParserNodeFunctionEvaluator $nodeVisitor, User $user, Logger $logger, $debug = FALSE) {
+ $this->nodeVisitor = $nodeVisitor;
+ $this->user = $user;
+ $this->parser = new Parser(new EmulativeLexer);
+ $this->traverser = new NodeTraverser;
$this->traverser->addVisitor($nodeVisitor);
$this->prettyPrinter = new StandardPrettyPrinter;
- $this->logger = $logger;
+ $this->logger = $logger;
$this->debug = $debug;
}
@@ -90,8 +90,7 @@ class AccessConditionExpression
* @param array[mixed] $params the parameters to be used when evaluating the expression.
* @return bool true if the condition is passed for the given parameters, otherwise returns false.
*/
- public function evaluateCondition($condition, $params)
- {
+ public function evaluateCondition($condition, $params) {
// Set the reserved `self` parameters.
// This replaces any values of `self` specified in the arguments, thus preventing them from being overridden in malicious user input.
// (For example, from an unfiltered request body).
@@ -120,7 +119,7 @@ class AccessConditionExpression
$result = eval($expr_eval);
if ($this->debug) {
- $this->logger->debug("Expression '$expr' evaluates to " . ($result == true ? "true" : "false"));
+ $this->logger->debug("Expression '$expr' evaluates to " . ($result == TRUE ? "true" : "false"));
}
return $result;
@@ -128,12 +127,12 @@ class AccessConditionExpression
if ($this->debug) {
$this->logger->debug("Error parsing access condition '$condition':" . $e->getMessage());
}
- return false; // Access fails if the access condition can't be parsed.
+ return FALSE; // Access fails if the access condition can't be parsed.
} catch (AuthorizationException $e) {
if ($this->debug) {
$this->logger->debug("Error parsing access condition '$condition':" . $e->getMessage());
}
- return false;
+ return FALSE;
}
}
}
diff --git a/main/app/sprinkles/account/src/Authorize/AuthorizationException.php b/main/app/sprinkles/account/src/Authorize/AuthorizationException.php
index 251b67f..33f3d35 100644
--- a/main/app/sprinkles/account/src/Authorize/AuthorizationException.php
+++ b/main/app/sprinkles/account/src/Authorize/AuthorizationException.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Authorize;
use UserFrosting\Support\Exception\ForbiddenException;
diff --git a/main/app/sprinkles/account/src/Authorize/AuthorizationManager.php b/main/app/sprinkles/account/src/Authorize/AuthorizationManager.php
index def152b..f9fb196 100644
--- a/main/app/sprinkles/account/src/Authorize/AuthorizationManager.php
+++ b/main/app/sprinkles/account/src/Authorize/AuthorizationManager.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Authorize;
use Interop\Container\ContainerInterface;
@@ -33,8 +34,7 @@ class AuthorizationManager
*
* @param ContainerInterface $ci The global container object, which holds all your services.
*/
- public function __construct(ContainerInterface $ci, array $callbacks = [])
- {
+ public function __construct(ContainerInterface $ci, array $callbacks = []) {
$this->ci = $ci;
$this->callbacks = $callbacks;
}
@@ -46,8 +46,7 @@ class AuthorizationManager
* @param string $name
* @param callable $callback
*/
- public function addCallback($name, $callback)
- {
+ public function addCallback($name, $callback) {
$this->callbacks[$name] = $callback;
return $this;
}
@@ -57,8 +56,7 @@ class AuthorizationManager
*
* @return callable[]
*/
- public function getCallbacks()
- {
+ public function getCallbacks() {
return $this->callbacks;
}
@@ -69,12 +67,11 @@ class AuthorizationManager
*
* @param UserFrosting\Sprinkle\Account\Database\Models\User $user
* @param string $slug The permission slug to check for access.
- * @param array $params[optional] An array of field names => values, specifying any additional data to provide the authorization module
+ * @param array $params [optional] An array of field names => values, specifying any additional data to provide the authorization module
* when determining whether or not this user has access.
* @return boolean True if the user has access, false otherwise.
*/
- public function checkAccess(User $user, $slug, array $params = [])
- {
+ public function checkAccess(User $user, $slug, array $params = []) {
$debug = $this->ci->config['debug.auth'];
if ($debug) {
@@ -87,7 +84,7 @@ class AuthorizationManager
if ($debug) {
$this->ci->authLogger->debug("User is not logged in. Access denied.");
}
- return false;
+ return FALSE;
}
// The master (root) account has access to everything.
@@ -97,7 +94,7 @@ class AuthorizationManager
if ($debug) {
$this->ci->authLogger->debug("User is the master (root) user. Access granted.");
}
- return true;
+ return TRUE;
}
// Find all permissions that apply to this user (via roles), and check if any evaluate to true.
@@ -107,13 +104,13 @@ class AuthorizationManager
if ($debug) {
$this->ci->authLogger->debug("No matching permissions found. Access denied.");
}
- return false;
+ return FALSE;
}
$permissions = $permissions[$slug];
if ($debug) {
- $this->ci->authLogger->debug("Found matching permissions: \n" . print_r($this->getPermissionsArrayDebugInfo($permissions), true));
+ $this->ci->authLogger->debug("Found matching permissions: \n" . print_r($this->getPermissionsArrayDebugInfo($permissions), TRUE));
}
$nodeVisitor = new ParserNodeFunctionEvaluator($this->callbacks, $this->ci->authLogger, $debug);
@@ -125,7 +122,7 @@ class AuthorizationManager
if ($debug) {
$this->ci->authLogger->debug("User passed conditions '{$permission->conditions}' . Access granted.");
}
- return true;
+ return TRUE;
}
}
@@ -133,7 +130,7 @@ class AuthorizationManager
$this->ci->authLogger->debug("User failed to pass any of the matched permissions. Access denied.");
}
- return false;
+ return FALSE;
}
/**
@@ -142,8 +139,7 @@ class AuthorizationManager
* @param array
* @return array
*/
- protected function getPermissionsArrayDebugInfo($permissions)
- {
+ protected function getPermissionsArrayDebugInfo($permissions) {
$permissionsInfo = [];
foreach ($permissions as $permission) {
$permissionData = array_only($permission->toArray(), ['id', 'slug', 'name', 'conditions', 'description']);
diff --git a/main/app/sprinkles/account/src/Authorize/ParserNodeFunctionEvaluator.php b/main/app/sprinkles/account/src/Authorize/ParserNodeFunctionEvaluator.php
index e8e5cde..e0db07d 100644
--- a/main/app/sprinkles/account/src/Authorize/ParserNodeFunctionEvaluator.php
+++ b/main/app/sprinkles/account/src/Authorize/ParserNodeFunctionEvaluator.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Authorize;
use Monolog\Logger;
@@ -53,17 +54,15 @@ class ParserNodeFunctionEvaluator extends NodeVisitorAbstract
* @param Logger $logger A Monolog logger, used to dump debugging info for authorization evaluations.
* @param bool $debug Set to true if you want debugging information printed to the auth log.
*/
- public function __construct($callbacks, $logger, $debug = false)
- {
+ public function __construct($callbacks, $logger, $debug = FALSE) {
$this->callbacks = $callbacks;
$this->prettyPrinter = new StandardPrettyPrinter;
- $this->logger = $logger;
+ $this->logger = $logger;
$this->debug = $debug;
$this->params = [];
}
- public function leaveNode(Node $node)
- {
+ public function leaveNode(Node $node) {
// Look for function calls
if ($node instanceof \PhpParser\Node\Expr\FuncCall) {
$eval = new \PhpParser\Node\Scalar\LNumber;
@@ -87,26 +86,26 @@ class ParserNodeFunctionEvaluator extends NodeVisitorAbstract
$value = $this->resolveParamPath($argString);
$currentArgInfo['type'] = "parameter";
$currentArgInfo['resolved_value'] = $value;
- // Resolve arrays
- } elseif ($arg->value instanceof \PhpParser\Node\Expr\Array_) {
+ // Resolve arrays
+ } else if ($arg->value instanceof \PhpParser\Node\Expr\Array_) {
$value = $this->resolveArray($arg);
$currentArgInfo['type'] = "array";
- $currentArgInfo['resolved_value'] = print_r($value, true);
- // Resolve strings
- } elseif ($arg->value instanceof \PhpParser\Node\Scalar\String_) {
+ $currentArgInfo['resolved_value'] = print_r($value, TRUE);
+ // Resolve strings
+ } else if ($arg->value instanceof \PhpParser\Node\Scalar\String_) {
$value = $arg->value->value;
$currentArgInfo['type'] = "string";
$currentArgInfo['resolved_value'] = $value;
- // Resolve numbers
- } elseif ($arg->value instanceof \PhpParser\Node\Scalar\DNumber) {
+ // Resolve numbers
+ } else if ($arg->value instanceof \PhpParser\Node\Scalar\DNumber) {
$value = $arg->value->value;
$currentArgInfo['type'] = "float";
$currentArgInfo['resolved_value'] = $value;
- } elseif ($arg->value instanceof \PhpParser\Node\Scalar\LNumber) {
+ } else if ($arg->value instanceof \PhpParser\Node\Scalar\LNumber) {
$value = $arg->value->value;
$currentArgInfo['type'] = "integer";
$currentArgInfo['resolved_value'] = $value;
- // Anything else is simply interpreted as its literal string value
+ // Anything else is simply interpreted as its literal string value
} else {
$value = $argString;
$currentArgInfo['type'] = "unknown";
@@ -140,8 +139,7 @@ class ParserNodeFunctionEvaluator extends NodeVisitorAbstract
}
}
- public function setParams($params)
- {
+ public function setParams($params) {
$this->params = $params;
}
@@ -151,10 +149,9 @@ class ParserNodeFunctionEvaluator extends NodeVisitorAbstract
* @param string $arg the array, represented as a string.
* @return array[mixed] the array, as a plain ol' PHP array.
*/
- private function resolveArray($arg)
- {
+ private function resolveArray($arg) {
$arr = [];
- $items = (array) $arg->value->items;
+ $items = (array)$arg->value->items;
foreach ($items as $item) {
if ($item->key) {
$arr[$item->key] = $item->value->value;
@@ -172,8 +169,7 @@ class ParserNodeFunctionEvaluator extends NodeVisitorAbstract
* @throws Exception the path could not be resolved. Path is malformed or key does not exist.
* @return mixed the value of the specified parameter.
*/
- private function resolveParamPath($path)
- {
+ private function resolveParamPath($path) {
$pathTokens = explode(".", $path);
$value = $this->params;
foreach ($pathTokens as $token) {
@@ -181,7 +177,7 @@ class ParserNodeFunctionEvaluator extends NodeVisitorAbstract
if (is_array($value) && isset($value[$token])) {
$value = $value[$token];
continue;
- } elseif (is_object($value) && isset($value->$token)) {
+ } else if (is_object($value) && isset($value->$token)) {
$value = $value->$token;
continue;
} else {
diff --git a/main/app/sprinkles/account/src/Bakery/CreateAdminUser.php b/main/app/sprinkles/account/src/Bakery/CreateAdminUser.php
index cfaacef..f928a2c 100644
--- a/main/app/sprinkles/account/src/Bakery/CreateAdminUser.php
+++ b/main/app/sprinkles/account/src/Bakery/CreateAdminUser.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Bakery;
use Illuminate\Database\Capsule\Manager as Capsule;
@@ -40,17 +41,15 @@ class CreateAdminUser extends BaseCommand
/**
* {@inheritDoc}
*/
- protected function configure()
- {
+ protected function configure() {
$this->setName("create-admin")
- ->setDescription("Create the initial admin (root) user account");
+ ->setDescription("Create the initial admin (root) user account");
}
/**
* {@inheritDoc}
*/
- protected function execute(InputInterface $input, OutputInterface $output)
- {
+ protected function execute(InputInterface $input, OutputInterface $output) {
$this->io->title("Root account setup");
// Need the database
@@ -65,8 +64,8 @@ class CreateAdminUser extends BaseCommand
// Need migration table
if (!Capsule::schema()->hasColumn('migrations', 'id')) {
- $this->io->error("Migrations doesn't appear to have been run! Make sure the database is properly migrated by using the `php bakery migrate` command.");
- exit(1);
+ $this->io->error("Migrations doesn't appear to have been run! Make sure the database is properly migrated by using the `php bakery migrate` command.");
+ exit(1);
}
// Make sure the required mirgations have been run
@@ -128,8 +127,7 @@ class CreateAdminUser extends BaseCommand
* @access protected
* @return void
*/
- protected function askUsername()
- {
+ protected function askUsername() {
while (!isset($userName) || !$this->validateUsername($userName)) {
$userName = $this->io->ask("Choose a root username (1-50 characters, no leading or trailing whitespace)");
}
@@ -143,12 +141,11 @@ class CreateAdminUser extends BaseCommand
* @param mixed $userName
* @return void
*/
- protected function validateUsername($userName)
- {
+ protected function validateUsername($userName) {
// Validate length
if (strlen($userName) < 1 || strlen($userName) > 50) {
$this->io->error("Username must be between 1-50 characters");
- return false;
+ return FALSE;
}
// Validate format
@@ -160,10 +157,10 @@ class CreateAdminUser extends BaseCommand
$validate = filter_var($userName, FILTER_VALIDATE_REGEXP, $options);
if (!$validate) {
$this->io->error("Username can't have any leading or trailing whitespace");
- return false;
+ return FALSE;
}
- return true;
+ return TRUE;
}
/**
@@ -172,8 +169,7 @@ class CreateAdminUser extends BaseCommand
* @access protected
* @return void
*/
- protected function askEmail()
- {
+ protected function askEmail() {
while (!isset($email) || !$this->validateEmail($email)) {
$email = $this->io->ask("Enter a valid email address (1-254 characters, must be compatible with FILTER_VALIDATE_EMAIL)");
}
@@ -187,21 +183,20 @@ class CreateAdminUser extends BaseCommand
* @param mixed $email
* @return void
*/
- protected function validateEmail($email)
- {
+ protected function validateEmail($email) {
// Validate length
if (strlen($email) < 1 || strlen($email) > 254) {
$this->io->error("Email must be between 1-254 characters");
- return false;
+ return FALSE;
}
// Validate format
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$this->io->error("Email must be compatible with FILTER_VALIDATE_EMAIL");
- return false;
+ return FALSE;
}
- return true;
+ return TRUE;
}
/**
@@ -210,8 +205,7 @@ class CreateAdminUser extends BaseCommand
* @access protected
* @return void
*/
- protected function askFirstName()
- {
+ protected function askFirstName() {
while (!isset($firstName) || !$this->validateFirstName($firstName)) {
$firstName = $this->io->ask("Enter the user first name (1-20 characters)");
}
@@ -225,15 +219,14 @@ class CreateAdminUser extends BaseCommand
* @param mixed $name
* @return void
*/
- protected function validateFirstName($firstName)
- {
+ protected function validateFirstName($firstName) {
// Validate length
if (strlen($firstName) < 1 || strlen($firstName) > 20) {
$this->io->error("First name must be between 1-20 characters");
- return false;
+ return FALSE;
}
- return true;
+ return TRUE;
}
/**
@@ -242,8 +235,7 @@ class CreateAdminUser extends BaseCommand
* @access protected
* @return void
*/
- protected function askLastName()
- {
+ protected function askLastName() {
while (!isset($lastName) || !$this->validateLastName($lastName)) {
$lastName = $this->io->ask("Enter the user last name (1-30 characters)");
}
@@ -257,15 +249,14 @@ class CreateAdminUser extends BaseCommand
* @param mixed $lastName
* @return void
*/
- protected function validateLastName($lastName)
- {
+ protected function validateLastName($lastName) {
// Validate length
if (strlen($lastName) < 1 || strlen($lastName) > 30) {
$this->io->error("Last name must be between 1-30 characters");
- return false;
+ return FALSE;
}
- return true;
+ return TRUE;
}
/**
@@ -274,8 +265,7 @@ class CreateAdminUser extends BaseCommand
* @access protected
* @return void
*/
- protected function askPassword()
- {
+ protected function askPassword() {
while (!isset($password) || !$this->validatePassword($password) || !$this->confirmPassword($password)) {
$password = $this->io->askHidden("Enter password (12-255 characters)");
}
@@ -289,14 +279,13 @@ class CreateAdminUser extends BaseCommand
* @param mixed $password
* @return void
*/
- protected function validatePassword($password)
- {
+ protected function validatePassword($password) {
if (strlen($password) < 12 || strlen($password) > 255) {
$this->io->error("Password must be between 12-255 characters");
- return false;
+ return FALSE;
}
- return true;
+ return TRUE;
}
/**
@@ -306,8 +295,7 @@ class CreateAdminUser extends BaseCommand
* @param mixed $passwordToConfirm
* @return void
*/
- protected function confirmPassword($passwordToConfirm)
- {
+ protected function confirmPassword($passwordToConfirm) {
while (!isset($password)) {
$password = $this->io->askHidden("Please re-enter the chosen password");
}
@@ -322,13 +310,12 @@ class CreateAdminUser extends BaseCommand
* @param mixed $passwordToConfirm
* @return void
*/
- protected function validatePasswordConfirmation($password, $passwordToConfirm)
- {
+ protected function validatePasswordConfirmation($password, $passwordToConfirm) {
if ($password != $passwordToConfirm) {
$this->io->error("Passwords do not match, please try again.");
- return false;
+ return FALSE;
}
- return true;
+ return TRUE;
}
} \ No newline at end of file
diff --git a/main/app/sprinkles/account/src/Controller/AccountController.php b/main/app/sprinkles/account/src/Controller/AccountController.php
index ce99370..25961ec 100644
--- a/main/app/sprinkles/account/src/Controller/AccountController.php
+++ b/main/app/sprinkles/account/src/Controller/AccountController.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Controller;
use Carbon\Carbon;
@@ -47,8 +48,7 @@ class AccountController extends SimpleController
* @param array $args
* @return void
*/
- public function checkUsername(Request $request, Response $response, $args)
- {
+ public function checkUsername(Request $request, Response $response, $args) {
/** @var \UserFrosting\Sprinkle\Core\Alert\AlertStream $ms */
$ms = $this->ci->alerts;
@@ -68,7 +68,7 @@ class AccountController extends SimpleController
// TODO: encapsulate the communication of error messages from ServerSideValidator to the BadRequestException
$e = new BadRequestException('Missing or malformed request data!');
foreach ($validator->errors() as $idx => $field) {
- foreach($field as $eidx => $error) {
+ foreach ($field as $eidx => $error) {
$e->addUserMessage($error);
}
}
@@ -114,8 +114,7 @@ class AccountController extends SimpleController
* @param array $args
* @return void
*/
- public function denyResetPassword(Request $request, Response $response, $args)
- {
+ public function denyResetPassword(Request $request, Response $response, $args) {
// GET parameters
$params = $request->getQueryParams();
@@ -172,8 +171,7 @@ class AccountController extends SimpleController
* @param array $args
* @return void
*/
- public function forgotPassword(Request $request, Response $response, $args)
- {
+ public function forgotPassword(Request $request, Response $response, $args) {
/** @var \UserFrosting\Sprinkle\Core\Alert\AlertStream $ms */
$ms = $this->ci->alerts;
@@ -217,7 +215,7 @@ class AccountController extends SimpleController
// All checks passed! log events/activities, update user, and send email
// Begin transaction - DB will be rolled back if an exception occurs
- Capsule::transaction( function() use ($classMapper, $data, $throttler, $throttleData, $config) {
+ Capsule::transaction(function () use ($classMapper, $data, $throttler, $throttleData, $config) {
// Log throttleable event
$throttler->logEvent('password_reset_request', $throttleData);
@@ -235,12 +233,12 @@ class AccountController extends SimpleController
// Create and send email
$message = new TwigMailMessage($this->ci->view, 'mail/password-reset.html.twig');
$message->from($config['address_book.admin'])
- ->addEmailRecipient(new EmailRecipient($user->email, $user->full_name))
- ->addParams([
- 'user' => $user,
- 'token' => $passwordReset->getToken(),
- 'request_date' => Carbon::now()->format('Y-m-d H:i:s')
- ]);
+ ->addEmailRecipient(new EmailRecipient($user->email, $user->full_name))
+ ->addParams([
+ 'user' => $user,
+ 'token' => $passwordReset->getToken(),
+ 'request_date' => Carbon::now()->format('Y-m-d H:i:s')
+ ]);
$this->ci->mailer->send($message);
}
@@ -263,8 +261,7 @@ class AccountController extends SimpleController
* @param array $args
* @return void
*/
- public function getModalAccountTos(Request $request, Response $response, $args)
- {
+ public function getModalAccountTos(Request $request, Response $response, $args) {
return $this->ci->view->render($response, 'modals/tos.html.twig');
}
@@ -278,14 +275,13 @@ class AccountController extends SimpleController
* @param array $args
* @return void
*/
- public function imageCaptcha(Request $request, Response $response, $args)
- {
+ public function imageCaptcha(Request $request, Response $response, $args) {
$captcha = new Captcha($this->ci->session, $this->ci->config['session.keys.captcha']);
$captcha->generateRandomCode();
return $response->withStatus(200)
- ->withHeader('Content-Type', 'image/png;base64')
- ->write($captcha->getImage());
+ ->withHeader('Content-Type', 'image/png;base64')
+ ->write($captcha->getImage());
}
/**
@@ -306,8 +302,7 @@ class AccountController extends SimpleController
* @param array $args
* @return void
*/
- public function login(Request $request, Response $response, $args)
- {
+ public function login(Request $request, Response $response, $args) {
/** @var \UserFrosting\Sprinkle\Core\Alert\AlertStream $ms */
$ms = $this->ci->alerts;
@@ -399,8 +394,7 @@ class AccountController extends SimpleController
* @param array $args
* @return void
*/
- public function logout(Request $request, Response $response, $args)
- {
+ public function logout(Request $request, Response $response, $args) {
// Destroy the session
$this->ci->authenticator->logout();
@@ -421,8 +415,7 @@ class AccountController extends SimpleController
* @param array $args
* @return void
*/
- public function pageForgotPassword(Request $request, Response $response, $args)
- {
+ public function pageForgotPassword(Request $request, Response $response, $args) {
// Load validation rules
$schema = new RequestSchema('schema://requests/forgot-password.yaml');
$validator = new JqueryValidationAdapter($schema, $this->ci->translator);
@@ -430,7 +423,7 @@ class AccountController extends SimpleController
return $this->ci->view->render($response, 'pages/forgot-password.html.twig', [
'page' => [
'validators' => [
- 'forgot_password' => $validator->rules('json', false)
+ 'forgot_password' => $validator->rules('json', FALSE)
]
]
]);
@@ -449,8 +442,7 @@ class AccountController extends SimpleController
* @param array $args
* @return void
*/
- public function pageRegister(Request $request, Response $response, $args)
- {
+ public function pageRegister(Request $request, Response $response, $args) {
/** @var \UserFrosting\Support\Repository\Repository $config */
$config = $this->ci->config;
@@ -475,7 +467,7 @@ class AccountController extends SimpleController
return $this->ci->view->render($response, 'pages/register.html.twig', [
'page' => [
'validators' => [
- 'register' => $validatorRegister->rules('json', false)
+ 'register' => $validatorRegister->rules('json', FALSE)
]
]
]);
@@ -493,8 +485,7 @@ class AccountController extends SimpleController
* @param array $args
* @return void
*/
- public function pageResendVerification(Request $request, Response $response, $args)
- {
+ public function pageResendVerification(Request $request, Response $response, $args) {
// Load validation rules
$schema = new RequestSchema('schema://requests/resend-verification.yaml');
$validator = new JqueryValidationAdapter($schema, $this->ci->translator);
@@ -502,7 +493,7 @@ class AccountController extends SimpleController
return $this->ci->view->render($response, 'pages/resend-verification.html.twig', [
'page' => [
'validators' => [
- 'resend_verification' => $validator->rules('json', false)
+ 'resend_verification' => $validator->rules('json', FALSE)
]
]
]);
@@ -519,8 +510,7 @@ class AccountController extends SimpleController
* @param array $args
* @return void
*/
- public function pageResetPassword(Request $request, Response $response, $args)
- {
+ public function pageResetPassword(Request $request, Response $response, $args) {
// Insert the user's secret token from the link into the password reset form
$params = $request->getQueryParams();
@@ -531,7 +521,7 @@ class AccountController extends SimpleController
return $this->ci->view->render($response, 'pages/reset-password.html.twig', [
'page' => [
'validators' => [
- 'set_password' => $validator->rules('json', false)
+ 'set_password' => $validator->rules('json', FALSE)
]
],
'token' => isset($params['token']) ? $params['token'] : '',
@@ -550,8 +540,7 @@ class AccountController extends SimpleController
* @param array $args
* @return void
*/
- public function pageSetPassword(Request $request, Response $response, $args)
- {
+ public function pageSetPassword(Request $request, Response $response, $args) {
// Insert the user's secret token from the link into the password set form
$params = $request->getQueryParams();
@@ -562,7 +551,7 @@ class AccountController extends SimpleController
return $this->ci->view->render($response, 'pages/set-password.html.twig', [
'page' => [
'validators' => [
- 'set_password' => $validator->rules('json', false)
+ 'set_password' => $validator->rules('json', FALSE)
]
],
'token' => isset($params['token']) ? $params['token'] : '',
@@ -582,8 +571,7 @@ class AccountController extends SimpleController
* @param array $args
* @return void
*/
- public function pageSettings(Request $request, Response $response, $args)
- {
+ public function pageSettings(Request $request, Response $response, $args) {
/** @var \UserFrosting\Sprinkle\Account\Authorize\AuthorizationManager */
$authorizer = $this->ci->authorizer;
@@ -612,8 +600,8 @@ class AccountController extends SimpleController
'locales' => $locales,
'page' => [
'validators' => [
- 'account_settings' => $validatorAccountSettings->rules('json', false),
- 'profile_settings' => $validatorProfileSettings->rules('json', false)
+ 'account_settings' => $validatorAccountSettings->rules('json', FALSE),
+ 'profile_settings' => $validatorProfileSettings->rules('json', FALSE)
],
'visibility' => ($authorizer->checkAccess($currentUser, 'update_account_settings') ? '' : 'disabled')
]
@@ -632,8 +620,7 @@ class AccountController extends SimpleController
* @param array $args
* @return void
*/
- public function pageSignIn(Request $request, Response $response, $args)
- {
+ public function pageSignIn(Request $request, Response $response, $args) {
/** @var \UserFrosting\Support\Repository\Repository $config */
$config = $this->ci->config;
@@ -654,7 +641,7 @@ class AccountController extends SimpleController
return $this->ci->view->render($response, 'pages/sign-in.html.twig', [
'page' => [
'validators' => [
- 'login' => $validatorLogin->rules('json', false)
+ 'login' => $validatorLogin->rules('json', FALSE)
]
]
]);
@@ -674,8 +661,7 @@ class AccountController extends SimpleController
* @param array $args
* @return void
*/
- public function profile(Request $request, Response $response, $args)
- {
+ public function profile(Request $request, Response $response, $args) {
/** @var \UserFrosting\Sprinkle\Core\Alert\AlertStream $ms */
$ms = $this->ci->alerts;
@@ -708,20 +694,20 @@ class AccountController extends SimpleController
$transformer = new RequestDataTransformer($schema);
$data = $transformer->transform($params);
- $error = false;
+ $error = FALSE;
// Validate, and halt on validation errors.
$validator = new ServerSideValidator($schema, $this->ci->translator);
if (!$validator->validate($data)) {
$ms->addValidationErrors($validator);
- $error = true;
+ $error = TRUE;
}
// Check that locale is valid
$locales = $config->getDefined('site.locales.available');
if (!array_key_exists($data['locale'], $locales)) {
$ms->addMessageTranslated('danger', 'LOCALE.INVALID', $data);
- $error = true;
+ $error = TRUE;
}
if ($error) {
@@ -765,8 +751,7 @@ class AccountController extends SimpleController
* @param array $args
* @return void
*/
- public function register(Request $request, Response $response, $args)
- {
+ public function register(Request $request, Response $response, $args) {
/** @var \UserFrosting\Sprinkle\Core\Alert\AlertStream $ms */
$ms = $this->ci->alerts;
@@ -781,7 +766,7 @@ class AccountController extends SimpleController
// Check the honeypot. 'spiderbro' is not a real field, it is hidden on the main page and must be submitted with its default value for this to be processed.
if (!isset($params['spiderbro']) || $params['spiderbro'] != 'http://') {
- throw new SpammyRequestException('Possible spam received:' . print_r($params, true));
+ throw new SpammyRequestException('Possible spam received:' . print_r($params, TRUE));
}
// Security measure: do not allow registering new users until the master account has been created.
@@ -812,13 +797,13 @@ class AccountController extends SimpleController
$transformer = new RequestDataTransformer($schema);
$data = $transformer->transform($params);
- $error = false;
+ $error = FALSE;
// Validate request data
$validator = new ServerSideValidator($schema, $this->ci->translator);
if (!$validator->validate($data)) {
$ms->addValidationErrors($validator);
- $error = true;
+ $error = TRUE;
}
/** @var \UserFrosting\Sprinkle\Core\Throttle\Throttler $throttler */
@@ -833,12 +818,12 @@ class AccountController extends SimpleController
// Check if username or email already exists
if ($classMapper->staticMethod('user', 'findUnique', $data['user_name'], 'user_name')) {
$ms->addMessageTranslated('danger', 'USERNAME.IN_USE', $data);
- $error = true;
+ $error = TRUE;
}
if ($classMapper->staticMethod('user', 'findUnique', $data['email'], 'email')) {
$ms->addMessageTranslated('danger', 'EMAIL.IN_USE', $data);
- $error = true;
+ $error = TRUE;
}
// Check captcha, if required
@@ -846,7 +831,7 @@ class AccountController extends SimpleController
$captcha = new Captcha($this->ci->session, $this->ci->config['session.keys.captcha']);
if (!$data['captcha'] || !$captcha->verifyCode($data['captcha'])) {
$ms->addMessageTranslated('danger', 'CAPTCHA.FAIL');
- $error = true;
+ $error = TRUE;
}
}
@@ -859,9 +844,9 @@ class AccountController extends SimpleController
unset($data['passwordc']);
if ($config['site.registration.require_email_verification']) {
- $data['flag_verified'] = false;
+ $data['flag_verified'] = FALSE;
} else {
- $data['flag_verified'] = true;
+ $data['flag_verified'] = TRUE;
}
// Load default group
@@ -885,7 +870,7 @@ class AccountController extends SimpleController
// All checks passed! log events/activities, create user, and send verification email (if required)
// Begin transaction - DB will be rolled back if an exception occurs
- Capsule::transaction( function() use ($classMapper, $data, $ms, $config, $throttler) {
+ Capsule::transaction(function () use ($classMapper, $data, $ms, $config, $throttler) {
// Log throttleable event
$throttler->logEvent('registration_attempt');
@@ -918,11 +903,11 @@ class AccountController extends SimpleController
$message = new TwigMailMessage($this->ci->view, 'mail/verify-account.html.twig');
$message->from($config['address_book.admin'])
- ->addEmailRecipient(new EmailRecipient($user->email, $user->full_name))
- ->addParams([
- 'user' => $user,
- 'token' => $verification->getToken()
- ]);
+ ->addEmailRecipient(new EmailRecipient($user->email, $user->full_name))
+ ->addParams([
+ 'user' => $user,
+ 'token' => $verification->getToken()
+ ]);
$this->ci->mailer->send($message);
@@ -952,8 +937,7 @@ class AccountController extends SimpleController
* @param array $args
* @return void
*/
- public function resendVerification(Request $request, Response $response, $args)
- {
+ public function resendVerification(Request $request, Response $response, $args) {
/** @var \UserFrosting\Sprinkle\Core\Alert\AlertStream $ms */
$ms = $this->ci->alerts;
@@ -997,7 +981,7 @@ class AccountController extends SimpleController
// All checks passed! log events/activities, create user, and send verification email (if required)
// Begin transaction - DB will be rolled back if an exception occurs
- Capsule::transaction( function() use ($classMapper, $data, $throttler, $throttleData, $config) {
+ Capsule::transaction(function () use ($classMapper, $data, $throttler, $throttleData, $config) {
// Log throttleable event
$throttler->logEvent('verification_request', $throttleData);
@@ -1015,11 +999,11 @@ class AccountController extends SimpleController
$message = new TwigMailMessage($this->ci->view, 'mail/resend-verification.html.twig');
$message->from($config['address_book.admin'])
- ->addEmailRecipient(new EmailRecipient($user->email, $user->full_name))
- ->addParams([
- 'user' => $user,
- 'token' => $verification->getToken()
- ]);
+ ->addEmailRecipient(new EmailRecipient($user->email, $user->full_name))
+ ->addParams([
+ 'user' => $user,
+ 'token' => $verification->getToken()
+ ]);
$this->ci->mailer->send($message);
}
@@ -1045,8 +1029,7 @@ class AccountController extends SimpleController
* @param array $args
* @return void
*/
- public function setPassword(Request $request, Response $response, $args)
- {
+ public function setPassword(Request $request, Response $response, $args) {
/** @var \UserFrosting\Sprinkle\Core\Alert\AlertStream $ms */
$ms = $this->ci->alerts;
@@ -1118,8 +1101,7 @@ class AccountController extends SimpleController
* @param array $args
* @return void
*/
- public function settings(Request $request, Response $response, $args)
- {
+ public function settings(Request $request, Response $response, $args) {
/** @var \UserFrosting\Sprinkle\Core\Alert\AlertStream $ms */
$ms = $this->ci->alerts;
@@ -1152,19 +1134,19 @@ class AccountController extends SimpleController
$transformer = new RequestDataTransformer($schema);
$data = $transformer->transform($params);
- $error = false;
+ $error = FALSE;
// Validate, and halt on validation errors.
$validator = new ServerSideValidator($schema, $this->ci->translator);
if (!$validator->validate($data)) {
$ms->addValidationErrors($validator);
- $error = true;
+ $error = TRUE;
}
// Confirm current password
if (!isset($data['passwordcheck']) || !Password::verify($data['passwordcheck'], $currentUser->password)) {
$ms->addMessageTranslated('danger', 'PASSWORD.INVALID');
- $error = true;
+ $error = TRUE;
}
// Remove password check, password confirmation from object data after validation
@@ -1174,7 +1156,7 @@ class AccountController extends SimpleController
// If new email was submitted, check that the email address is not in use
if (isset($data['email']) && $data['email'] != $currentUser->email && $classMapper->staticMethod('user', 'findUnique', $data['email'], 'email')) {
$ms->addMessageTranslated('danger', 'EMAIL.IN_USE', $data);
- $error = true;
+ $error = TRUE;
}
if ($error) {
@@ -1216,8 +1198,7 @@ class AccountController extends SimpleController
* @param array $args
* @return void
*/
- public function suggestUsername(Request $request, Response $response, $args)
- {
+ public function suggestUsername(Request $request, Response $response, $args) {
/** @var \UserFrosting\Sprinkle\Core\Alert\AlertStream $ms */
$ms = $this->ci->alerts;
@@ -1247,8 +1228,7 @@ class AccountController extends SimpleController
* @param array $args
* @return void
*/
- public function verify(Request $request, Response $response, $args)
- {
+ public function verify(Request $request, Response $response, $args) {
/** @var \UserFrosting\Sprinkle\Core\Alert\AlertStream $ms */
$ms = $this->ci->alerts;
diff --git a/main/app/sprinkles/account/src/Controller/Exception/SpammyRequestException.php b/main/app/sprinkles/account/src/Controller/Exception/SpammyRequestException.php
index 9713360..d66a16c 100644
--- a/main/app/sprinkles/account/src/Controller/Exception/SpammyRequestException.php
+++ b/main/app/sprinkles/account/src/Controller/Exception/SpammyRequestException.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Controller\Exception;
use UserFrosting\Support\Exception\HttpException;
diff --git a/main/app/sprinkles/account/src/Database/Migrations/v400/ActivitiesTable.php b/main/app/sprinkles/account/src/Database/Migrations/v400/ActivitiesTable.php
index 4e55c7c..db02ec2 100644
--- a/main/app/sprinkles/account/src/Database/Migrations/v400/ActivitiesTable.php
+++ b/main/app/sprinkles/account/src/Database/Migrations/v400/ActivitiesTable.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Database\Migrations\v400;
use UserFrosting\System\Bakery\Migration;
@@ -24,8 +25,7 @@ class ActivitiesTable extends Migration
/**
* {@inheritDoc}
*/
- public function up()
- {
+ public function up() {
if (!$this->schema->hasTable('activities')) {
$this->schema->create('activities', function (Blueprint $table) {
$table->increments('id');
@@ -47,8 +47,7 @@ class ActivitiesTable extends Migration
/**
* {@inheritDoc}
*/
- public function down()
- {
+ public function down() {
$this->schema->drop('activities');
}
} \ No newline at end of file
diff --git a/main/app/sprinkles/account/src/Database/Migrations/v400/GroupsTable.php b/main/app/sprinkles/account/src/Database/Migrations/v400/GroupsTable.php
index c74615f..07583af 100644
--- a/main/app/sprinkles/account/src/Database/Migrations/v400/GroupsTable.php
+++ b/main/app/sprinkles/account/src/Database/Migrations/v400/GroupsTable.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Database\Migrations\v400;
use Illuminate\Database\Schema\Blueprint;
@@ -26,15 +27,14 @@ class GroupsTable extends Migration
/**
* {@inheritDoc}
*/
- public function up()
- {
+ public function up() {
if (!$this->schema->hasTable('groups')) {
- $this->schema->create('groups', function(Blueprint $table) {
+ $this->schema->create('groups', function (Blueprint $table) {
$table->increments('id');
$table->string('slug');
$table->string('name');
$table->text('description')->nullable();
- $table->string('icon', 100)->nullable(false)->default('fa fa-user')->comment('The icon representing users in this group.');
+ $table->string('icon', 100)->nullable(FALSE)->default('fa fa-user')->comment('The icon representing users in this group.');
$table->timestamps();
$table->engine = 'InnoDB';
@@ -75,8 +75,7 @@ class GroupsTable extends Migration
/**
* {@inheritDoc}
*/
- public function down()
- {
+ public function down() {
$this->schema->drop('groups');
}
}
diff --git a/main/app/sprinkles/account/src/Database/Migrations/v400/PasswordResetsTable.php b/main/app/sprinkles/account/src/Database/Migrations/v400/PasswordResetsTable.php
index e785ccc..47eb00d 100644
--- a/main/app/sprinkles/account/src/Database/Migrations/v400/PasswordResetsTable.php
+++ b/main/app/sprinkles/account/src/Database/Migrations/v400/PasswordResetsTable.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Database\Migrations\v400;
use Illuminate\Database\Schema\Blueprint;
@@ -25,8 +26,7 @@ class passwordResetsTable extends Migration
/**
* {@inheritDoc}
*/
- public function up()
- {
+ public function up() {
if (!$this->schema->hasTable('password_resets')) {
$this->schema->create('password_resets', function (Blueprint $table) {
$table->increments('id');
@@ -50,8 +50,7 @@ class passwordResetsTable extends Migration
/**
* {@inheritDoc}
*/
- public function down()
- {
+ public function down() {
$this->schema->drop('password_resets');
}
}
diff --git a/main/app/sprinkles/account/src/Database/Migrations/v400/PermissionRolesTable.php b/main/app/sprinkles/account/src/Database/Migrations/v400/PermissionRolesTable.php
index 2c2990c..8e06cd6 100644
--- a/main/app/sprinkles/account/src/Database/Migrations/v400/PermissionRolesTable.php
+++ b/main/app/sprinkles/account/src/Database/Migrations/v400/PermissionRolesTable.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Database\Migrations\v400;
use Illuminate\Database\Schema\Blueprint;
@@ -25,8 +26,7 @@ class PermissionRolesTable extends Migration
/**
* {@inheritDoc}
*/
- public function up()
- {
+ public function up() {
if (!$this->schema->hasTable('permission_roles')) {
$this->schema->create('permission_roles', function (Blueprint $table) {
$table->integer('permission_id')->unsigned();
@@ -48,8 +48,7 @@ class PermissionRolesTable extends Migration
/**
* {@inheritDoc}
*/
- public function down()
- {
+ public function down() {
$this->schema->drop('permission_roles');
}
}
diff --git a/main/app/sprinkles/account/src/Database/Migrations/v400/PermissionsTable.php b/main/app/sprinkles/account/src/Database/Migrations/v400/PermissionsTable.php
index 684b01a..bef8cdd 100644
--- a/main/app/sprinkles/account/src/Database/Migrations/v400/PermissionsTable.php
+++ b/main/app/sprinkles/account/src/Database/Migrations/v400/PermissionsTable.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Database\Migrations\v400;
use Illuminate\Database\Schema\Blueprint;
@@ -36,10 +37,9 @@ class PermissionsTable extends Migration
/**
* {@inheritDoc}
*/
- public function up()
- {
+ public function up() {
if (!$this->schema->hasTable('permissions')) {
- $this->schema->create('permissions', function(Blueprint $table) {
+ $this->schema->create('permissions', function (Blueprint $table) {
$table->increments('id');
$table->string('slug')->comment('A code that references a specific action or URI that an assignee of this permission has access to.');
$table->string('name');
@@ -57,16 +57,14 @@ class PermissionsTable extends Migration
/**
* {@inheritDoc}
*/
- public function down()
- {
+ public function down() {
$this->schema->drop('permissions');
}
/**
* {@inheritDoc}
*/
- public function seed()
- {
+ public function seed() {
// Skip this if table is not empty
if (Permission::count() == 0) {
diff --git a/main/app/sprinkles/account/src/Database/Migrations/v400/PersistencesTable.php b/main/app/sprinkles/account/src/Database/Migrations/v400/PersistencesTable.php
index b96e327..41378d3 100644
--- a/main/app/sprinkles/account/src/Database/Migrations/v400/PersistencesTable.php
+++ b/main/app/sprinkles/account/src/Database/Migrations/v400/PersistencesTable.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Database\Migrations\v400;
use Illuminate\Database\Schema\Blueprint;
@@ -25,8 +26,7 @@ class PersistencesTable extends Migration
/**
* {@inheritDoc}
*/
- public function up()
- {
+ public function up() {
if (!$this->schema->hasTable('persistences')) {
$this->schema->create('persistences', function (Blueprint $table) {
$table->increments('id');
@@ -50,8 +50,7 @@ class PersistencesTable extends Migration
/**
* {@inheritDoc}
*/
- public function down()
- {
+ public function down() {
$this->schema->drop('persistences');
}
}
diff --git a/main/app/sprinkles/account/src/Database/Migrations/v400/RoleUsersTable.php b/main/app/sprinkles/account/src/Database/Migrations/v400/RoleUsersTable.php
index 7f3648b..4c7ca06 100644
--- a/main/app/sprinkles/account/src/Database/Migrations/v400/RoleUsersTable.php
+++ b/main/app/sprinkles/account/src/Database/Migrations/v400/RoleUsersTable.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Database\Migrations\v400;
use Illuminate\Database\Schema\Blueprint;
@@ -25,8 +26,7 @@ class RoleUsersTable extends Migration
/**
* {@inheritDoc}
*/
- public function up()
- {
+ public function up() {
if (!$this->schema->hasTable('role_users')) {
$this->schema->create('role_users', function (Blueprint $table) {
$table->integer('user_id')->unsigned();
@@ -48,8 +48,7 @@ class RoleUsersTable extends Migration
/**
* {@inheritDoc}
*/
- public function down()
- {
+ public function down() {
$this->schema->drop('role_users');
}
}
diff --git a/main/app/sprinkles/account/src/Database/Migrations/v400/RolesTable.php b/main/app/sprinkles/account/src/Database/Migrations/v400/RolesTable.php
index 9cef494..20fe699 100644
--- a/main/app/sprinkles/account/src/Database/Migrations/v400/RolesTable.php
+++ b/main/app/sprinkles/account/src/Database/Migrations/v400/RolesTable.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Database\Migrations\v400;
use Illuminate\Database\Schema\Blueprint;
@@ -26,8 +27,7 @@ class RolesTable extends Migration
/**
* {@inheritDoc}
*/
- public function up()
- {
+ public function up() {
if (!$this->schema->hasTable('roles')) {
$this->schema->create('roles', function (Blueprint $table) {
$table->increments('id');
@@ -71,8 +71,7 @@ class RolesTable extends Migration
/**
* {@inheritDoc}
*/
- public function down()
- {
+ public function down() {
$this->schema->drop('roles');
}
}
diff --git a/main/app/sprinkles/account/src/Database/Migrations/v400/UsersTable.php b/main/app/sprinkles/account/src/Database/Migrations/v400/UsersTable.php
index a65eeed..9c634e8 100644
--- a/main/app/sprinkles/account/src/Database/Migrations/v400/UsersTable.php
+++ b/main/app/sprinkles/account/src/Database/Migrations/v400/UsersTable.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Database\Migrations\v400;
use Illuminate\Database\Schema\Blueprint;
@@ -25,8 +26,7 @@ class UsersTable extends Migration
/**
* {@inheritDoc}
*/
- public function up()
- {
+ public function up() {
if (!$this->schema->hasTable('users')) {
$this->schema->create('users', function (Blueprint $table) {
$table->increments('id');
@@ -62,8 +62,7 @@ class UsersTable extends Migration
/**
* {@inheritDoc}
*/
- public function down()
- {
+ public function down() {
$this->schema->drop('users');
}
}
diff --git a/main/app/sprinkles/account/src/Database/Migrations/v400/VerificationsTable.php b/main/app/sprinkles/account/src/Database/Migrations/v400/VerificationsTable.php
index fa54da6..e42114c 100644
--- a/main/app/sprinkles/account/src/Database/Migrations/v400/VerificationsTable.php
+++ b/main/app/sprinkles/account/src/Database/Migrations/v400/VerificationsTable.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Database\Migrations\v400;
use Illuminate\Database\Schema\Blueprint;
@@ -25,8 +26,7 @@ class VerificationsTable extends Migration
/**
* {@inheritDoc}
*/
- public function up()
- {
+ public function up() {
if (!$this->schema->hasTable('verifications')) {
$this->schema->create('verifications', function (Blueprint $table) {
$table->increments('id');
@@ -50,8 +50,7 @@ class VerificationsTable extends Migration
/**
* {@inheritDoc}
*/
- public function down()
- {
+ public function down() {
$this->schema->drop('verifications');
}
}
diff --git a/main/app/sprinkles/account/src/Database/Models/Activity.php b/main/app/sprinkles/account/src/Database/Models/Activity.php
index d5be589..4e5b609 100644
--- a/main/app/sprinkles/account/src/Database/Models/Activity.php
+++ b/main/app/sprinkles/account/src/Database/Models/Activity.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Database\Models;
use Illuminate\Database\Capsule\Manager as Capsule;
@@ -39,8 +40,7 @@ class Activity extends Model
/**
* Joins the activity's user, so we can do things like sort, search, paginate, etc.
*/
- public function scopeJoinUser($query)
- {
+ public function scopeJoinUser($query) {
$query = $query->select('activities.*');
$query = $query->leftJoin('users', 'activities.user_id', '=', 'users.id');
@@ -53,8 +53,7 @@ class Activity extends Model
*
* @return \Illuminate\Database\Query\Builder
*/
- public function scopeMostRecentEvents($query)
- {
+ public function scopeMostRecentEvents($query) {
return $query->select('user_id', 'event_type', Capsule::raw('MAX(occurred_at) as occurred_at'))
->groupBy('user_id')
->groupBy('type');
@@ -66,8 +65,7 @@ class Activity extends Model
* @param string $type The type of event, matching the `event_type` field in the user_event table.
* @return \Illuminate\Database\Query\Builder
*/
- public function scopeMostRecentEventsByType($query, $type)
- {
+ public function scopeMostRecentEventsByType($query, $type) {
return $query->select('user_id', Capsule::raw('MAX(occurred_at) as occurred_at'))
->where('type', $type)
->groupBy('user_id');
@@ -76,8 +74,7 @@ class Activity extends Model
/**
* Get the user associated with this activity.
*/
- public function user()
- {
+ public function user() {
/** @var UserFrosting\Sprinkle\Core\Util\ClassMapper $classMapper */
$classMapper = static::$ci->classMapper;
diff --git a/main/app/sprinkles/account/src/Database/Models/Group.php b/main/app/sprinkles/account/src/Database/Models/Group.php
index f10e066..b904eb5 100644
--- a/main/app/sprinkles/account/src/Database/Models/Group.php
+++ b/main/app/sprinkles/account/src/Database/Models/Group.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Database\Models;
use Illuminate\Database\Capsule\Manager as Capsule;
@@ -41,15 +42,14 @@ class Group extends Model
/**
* @var bool Enable timestamps for this class.
*/
- public $timestamps = true;
+ public $timestamps = TRUE;
/**
* Delete this group from the database, along with any user associations
*
* @todo What do we do with users when their group is deleted? Reassign them? Or, can a user be "groupless"?
*/
- public function delete()
- {
+ public function delete() {
// Delete the group
$result = parent::delete();
@@ -59,8 +59,7 @@ class Group extends Model
/**
* Lazily load a collection of Users which belong to this group.
*/
- public function users()
- {
+ public function users() {
/** @var UserFrosting\Sprinkle\Core\Util\ClassMapper $classMapper */
$classMapper = static::$ci->classMapper;
diff --git a/main/app/sprinkles/account/src/Database/Models/PasswordReset.php b/main/app/sprinkles/account/src/Database/Models/PasswordReset.php
index ac8a930..3fc4e3c 100644
--- a/main/app/sprinkles/account/src/Database/Models/PasswordReset.php
+++ b/main/app/sprinkles/account/src/Database/Models/PasswordReset.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Database\Models;
use Illuminate\Database\Capsule\Manager as Capsule;
@@ -39,7 +40,7 @@ class PasswordReset extends Model
/**
* @var bool Enable timestamps for PasswordResets.
*/
- public $timestamps = true;
+ public $timestamps = TRUE;
/**
* Stores the raw (unhashed) token when created, so that it can be emailed out to the user. NOT persisted.
@@ -49,16 +50,14 @@ class PasswordReset extends Model
/**
* @return string
*/
- public function getToken()
- {
+ public function getToken() {
return $this->token;
}
/**
* @param string $value
*/
- public function setToken($value)
- {
+ public function setToken($value) {
$this->token = $value;
return $this;
}
@@ -66,8 +65,7 @@ class PasswordReset extends Model
/**
* Get the user associated with this reset request.
*/
- public function user()
- {
+ public function user() {
/** @var UserFrosting\Sprinkle\Core\Util\ClassMapper $classMapper */
$classMapper = static::$ci->classMapper;
diff --git a/main/app/sprinkles/account/src/Database/Models/Permission.php b/main/app/sprinkles/account/src/Database/Models/Permission.php
index 463af8d..3035e56 100644
--- a/main/app/sprinkles/account/src/Database/Models/Permission.php
+++ b/main/app/sprinkles/account/src/Database/Models/Permission.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Database\Models;
use Illuminate\Database\Capsule\Manager as Capsule;
@@ -37,14 +38,13 @@ class Permission extends Model
/**
* @var bool Enable timestamps for this class.
*/
- public $timestamps = true;
+ public $timestamps = TRUE;
/**
* Delete this permission from the database, removing associations with roles.
*
*/
- public function delete()
- {
+ public function delete() {
// Remove all role associations
$this->roles()->detach();
@@ -59,8 +59,7 @@ class Permission extends Model
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
- public function roles()
- {
+ public function roles() {
/** @var UserFrosting\Sprinkle\Core\Util\ClassMapper $classMapper */
$classMapper = static::$ci->classMapper;
@@ -74,11 +73,10 @@ class Permission extends Model
* @param int $roleId
* @return \Illuminate\Database\Eloquent\Builder
*/
- public function scopeForRole($query, $roleId)
- {
+ public function scopeForRole($query, $roleId) {
return $query->join('permission_roles', function ($join) use ($roleId) {
$join->on('permission_roles.permission_id', 'permissions.id')
- ->where('role_id', $roleId);
+ ->where('role_id', $roleId);
});
}
@@ -89,11 +87,10 @@ class Permission extends Model
* @param int $roleId
* @return \Illuminate\Database\Eloquent\Builder
*/
- public function scopeNotForRole($query, $roleId)
- {
+ public function scopeNotForRole($query, $roleId) {
return $query->join('permission_roles', function ($join) use ($roleId) {
$join->on('permission_roles.permission_id', 'permissions.id')
- ->where('role_id', '!=', $roleId);
+ ->where('role_id', '!=', $roleId);
});
}
@@ -102,8 +99,7 @@ class Permission extends Model
*
* @return \UserFrosting\Sprinkle\Core\Database\Relations\BelongsToManyThrough
*/
- public function users()
- {
+ public function users() {
/** @var UserFrosting\Sprinkle\Core\Util\ClassMapper $classMapper */
$classMapper = static::$ci->classMapper;
diff --git a/main/app/sprinkles/account/src/Database/Models/Role.php b/main/app/sprinkles/account/src/Database/Models/Role.php
index ce9cb8c..4a58df0 100644
--- a/main/app/sprinkles/account/src/Database/Models/Role.php
+++ b/main/app/sprinkles/account/src/Database/Models/Role.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Database\Models;
use Illuminate\Database\Capsule\Manager as Capsule;
@@ -35,14 +36,13 @@ class Role extends Model
/**
* @var bool Enable timestamps for this class.
*/
- public $timestamps = true;
+ public $timestamps = TRUE;
/**
* Delete this role from the database, removing associations with permissions and users.
*
*/
- public function delete()
- {
+ public function delete() {
// Remove all permission associations
$this->permissions()->detach();
@@ -58,19 +58,17 @@ class Role extends Model
/**
* Get a list of default roles.
*/
- public static function getDefaultSlugs()
- {
+ public static function getDefaultSlugs() {
/** @var UserFrosting\Config $config */
$config = static::$ci->config;
- return array_map('trim', array_keys($config['site.registration.user_defaults.roles'], true));
+ return array_map('trim', array_keys($config['site.registration.user_defaults.roles'], TRUE));
}
/**
* Get a list of permissions assigned to this role.
*/
- public function permissions()
- {
+ public function permissions() {
/** @var UserFrosting\Sprinkle\Core\Util\ClassMapper $classMapper */
$classMapper = static::$ci->classMapper;
@@ -84,19 +82,17 @@ class Role extends Model
* @param int $userId
* @return \Illuminate\Database\Eloquent\Builder
*/
- public function scopeForUser($query, $userId)
- {
+ public function scopeForUser($query, $userId) {
return $query->join('role_users', function ($join) use ($userId) {
$join->on('role_users.role_id', 'roles.id')
- ->where('user_id', $userId);
+ ->where('user_id', $userId);
});
}
/**
* Get a list of users who have this role.
*/
- public function users()
- {
+ public function users() {
/** @var UserFrosting\Sprinkle\Core\Util\ClassMapper $classMapper */
$classMapper = static::$ci->classMapper;
diff --git a/main/app/sprinkles/account/src/Database/Models/Verification.php b/main/app/sprinkles/account/src/Database/Models/Verification.php
index cd5166d..f6697b6 100644
--- a/main/app/sprinkles/account/src/Database/Models/Verification.php
+++ b/main/app/sprinkles/account/src/Database/Models/Verification.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Database\Models;
use Illuminate\Database\Capsule\Manager as Capsule;
@@ -39,20 +40,18 @@ class Verification extends Model
/**
* @var bool Enable timestamps for Verifications.
*/
- public $timestamps = true;
+ public $timestamps = TRUE;
/**
* Stores the raw (unhashed) token when created, so that it can be emailed out to the user. NOT persisted.
*/
protected $token;
- public function getToken()
- {
+ public function getToken() {
return $this->token;
}
- public function setToken($value)
- {
+ public function setToken($value) {
$this->token = $value;
return $this;
}
@@ -60,8 +59,7 @@ class Verification extends Model
/**
* Get the user associated with this verification request.
*/
- public function user()
- {
+ public function user() {
/** @var UserFrosting\Sprinkle\Core\Util\ClassMapper $classMapper */
$classMapper = static::$ci->classMapper;
diff --git a/main/app/sprinkles/account/src/Error/Handler/AuthCompromisedExceptionHandler.php b/main/app/sprinkles/account/src/Error/Handler/AuthCompromisedExceptionHandler.php
index 330ca65..4c3b100 100644
--- a/main/app/sprinkles/account/src/Error/Handler/AuthCompromisedExceptionHandler.php
+++ b/main/app/sprinkles/account/src/Error/Handler/AuthCompromisedExceptionHandler.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Error\Handler;
use UserFrosting\Sprinkle\Core\Error\Handler\HttpExceptionHandler;
@@ -22,8 +23,7 @@ class AuthCompromisedExceptionHandler extends HttpExceptionHandler
*
* @return ResponseInterface
*/
- public function renderGenericResponse()
- {
+ public function renderGenericResponse() {
$template = $this->ci->view->getEnvironment()->loadTemplate('pages/error/compromised.html.twig');
return $this->response
diff --git a/main/app/sprinkles/account/src/Error/Handler/AuthExpiredExceptionHandler.php b/main/app/sprinkles/account/src/Error/Handler/AuthExpiredExceptionHandler.php
index c651f77..fd3ca1f 100644
--- a/main/app/sprinkles/account/src/Error/Handler/AuthExpiredExceptionHandler.php
+++ b/main/app/sprinkles/account/src/Error/Handler/AuthExpiredExceptionHandler.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Error\Handler;
use UserFrosting\Sprinkle\Core\Error\Handler\HttpExceptionHandler;
@@ -20,8 +21,7 @@ class AuthExpiredExceptionHandler extends HttpExceptionHandler
/**
* Custom handling for requests that did not pass authentication.
*/
- public function handle()
- {
+ public function handle() {
// For auth expired exceptions, we always add messages to the alert stream.
$this->writeAlerts();
@@ -33,11 +33,11 @@ class AuthExpiredExceptionHandler extends HttpExceptionHandler
$path = $uri->getPath();
$query = $uri->getQuery();
$fragment = $uri->getFragment();
-
+
$path = $path
. ($query ? '?' . $query : '')
. ($fragment ? '#' . $fragment : '');
-
+
$loginPage = $this->ci->router->pathFor('login', [], [
'redirect' => $path
]);
diff --git a/main/app/sprinkles/account/src/Error/Handler/ForbiddenExceptionHandler.php b/main/app/sprinkles/account/src/Error/Handler/ForbiddenExceptionHandler.php
index e22f02b..b418dde 100644
--- a/main/app/sprinkles/account/src/Error/Handler/ForbiddenExceptionHandler.php
+++ b/main/app/sprinkles/account/src/Error/Handler/ForbiddenExceptionHandler.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Error\Handler;
use UserFrosting\Sprinkle\Core\Error\Handler\HttpExceptionHandler;
@@ -22,8 +23,7 @@ class ForbiddenExceptionHandler extends HttpExceptionHandler
*
* @return array
*/
- protected function determineUserMessages()
- {
+ protected function determineUserMessages() {
return [
new UserMessage("ACCOUNT.ACCESS_DENIED")
];
diff --git a/main/app/sprinkles/account/src/Facades/Password.php b/main/app/sprinkles/account/src/Facades/Password.php
index e5bf967..0664b7a 100644
--- a/main/app/sprinkles/account/src/Facades/Password.php
+++ b/main/app/sprinkles/account/src/Facades/Password.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Facades;
use UserFrosting\System\Facade;
@@ -21,8 +22,7 @@ class Password extends Facade
*
* @return string
*/
- protected static function getFacadeAccessor()
- {
+ protected static function getFacadeAccessor() {
return 'passwordHasher';
}
}
diff --git a/main/app/sprinkles/account/src/Log/UserActivityDatabaseHandler.php b/main/app/sprinkles/account/src/Log/UserActivityDatabaseHandler.php
index d7ceeef..a1cd14f 100644
--- a/main/app/sprinkles/account/src/Log/UserActivityDatabaseHandler.php
+++ b/main/app/sprinkles/account/src/Log/UserActivityDatabaseHandler.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Log;
use UserFrosting\Sprinkle\Core\Log\DatabaseHandler;
@@ -19,8 +20,7 @@ class UserActivityDatabaseHandler extends DatabaseHandler
/**
* {@inheritDoc}
*/
- protected function write(array $record)
- {
+ protected function write(array $record) {
$log = $this->classMapper->createInstance($this->modelName, $record['extra']);
$log->save();
diff --git a/main/app/sprinkles/account/src/Log/UserActivityProcessor.php b/main/app/sprinkles/account/src/Log/UserActivityProcessor.php
index 2575270..f1aa8c7 100644
--- a/main/app/sprinkles/account/src/Log/UserActivityProcessor.php
+++ b/main/app/sprinkles/account/src/Log/UserActivityProcessor.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Log;
use Monolog\Logger;
@@ -24,16 +25,14 @@ class UserActivityProcessor
/**
* @param int $userId The id of the user for whom we will be logging activities.
*/
- public function __construct($userId)
- {
+ public function __construct($userId) {
$this->userId = $userId;
}
- public function __invoke(array $record)
- {
+ public function __invoke(array $record) {
$additionalFields = [
- 'ip_address' => $_SERVER['REMOTE_ADDR'],
- 'user_id' => $this->userId,
+ 'ip_address' => $_SERVER['REMOTE_ADDR'],
+ 'user_id' => $this->userId,
'occurred_at' => $record['datetime'],
'description' => $record['message']
];
diff --git a/main/app/sprinkles/account/src/Repository/PasswordResetRepository.php b/main/app/sprinkles/account/src/Repository/PasswordResetRepository.php
index 2dcffd3..e21b5d6 100644
--- a/main/app/sprinkles/account/src/Repository/PasswordResetRepository.php
+++ b/main/app/sprinkles/account/src/Repository/PasswordResetRepository.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Repository;
use UserFrosting\Sprinkle\Account\Facades\Password;
@@ -25,8 +26,7 @@ class PasswordResetRepository extends TokenRepository
/**
* {@inheritDoc}
*/
- protected function updateUser($user, $args)
- {
+ protected function updateUser($user, $args) {
$user->password = Password::hash($args['password']);
// TODO: generate user activity? or do this in controller?
$user->save();
diff --git a/main/app/sprinkles/account/src/Repository/TokenRepository.php b/main/app/sprinkles/account/src/Repository/TokenRepository.php
index a299439..5c2e34a 100644
--- a/main/app/sprinkles/account/src/Repository/TokenRepository.php
+++ b/main/app/sprinkles/account/src/Repository/TokenRepository.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Repository;
use Carbon\Carbon;
@@ -43,8 +44,7 @@ abstract class TokenRepository
* @param ClassMapper $classMapper Maps generic class identifiers to specific class names.
* @param string $algorithm The hashing algorithm to use when storing generated tokens.
*/
- public function __construct(ClassMapper $classMapper, $algorithm = 'sha512')
- {
+ public function __construct(ClassMapper $classMapper, $algorithm = 'sha512') {
$this->classMapper = $classMapper;
$this->algorithm = $algorithm;
}
@@ -55,19 +55,18 @@ abstract class TokenRepository
* @param int $token The token to remove.
* @return Model|false
*/
- public function cancel($token)
- {
+ public function cancel($token) {
// Hash the password reset token for the stored version
$hash = hash($this->algorithm, $token);
// Find an incomplete reset request for the specified hash
$model = $this->classMapper
->staticMethod($this->modelIdentifier, 'where', 'hash', $hash)
- ->where('completed', false)
+ ->where('completed', FALSE)
->first();
- if ($model === null) {
- return false;
+ if ($model === NULL) {
+ return FALSE;
}
$model->delete();
@@ -82,33 +81,32 @@ abstract class TokenRepository
* @param mixed[] $userParams An optional list of parameters to pass to updateUser().
* @return Model|false
*/
- public function complete($token, $userParams = [])
- {
+ public function complete($token, $userParams = []) {
// Hash the token for the stored version
$hash = hash($this->algorithm, $token);
// Find an unexpired, incomplete token for the specified hash
$model = $this->classMapper
->staticMethod($this->modelIdentifier, 'where', 'hash', $hash)
- ->where('completed', false)
+ ->where('completed', FALSE)
->where('expires_at', '>', Carbon::now())
->first();
- if ($model === null) {
- return false;
+ if ($model === NULL) {
+ return FALSE;
}
// Fetch user for this token
$user = $this->classMapper->staticMethod('user', 'find', $model->user_id);
if (is_null($user)) {
- return false;
+ return FALSE;
}
$this->updateUser($user, $userParams);
$model->fill([
- 'completed' => true,
+ 'completed' => TRUE,
'completed_at' => Carbon::now()
]);
@@ -124,8 +122,7 @@ abstract class TokenRepository
* @param int $timeout The time, in seconds, after which this token should expire.
* @return Model The model (PasswordReset, Verification, etc) object that stores the token.
*/
- public function create(User $user, $timeout)
- {
+ public function create(User $user, $timeout) {
// Remove any previous tokens for this user
$this->removeExisting($user);
@@ -141,8 +138,8 @@ abstract class TokenRepository
$hash = hash($this->algorithm, $model->getToken());
$model->fill([
- 'hash' => $hash,
- 'completed' => false,
+ 'hash' => $hash,
+ 'completed' => FALSE,
'expires_at' => $expiresAt
]);
@@ -160,11 +157,10 @@ abstract class TokenRepository
* @param int $token Optionally, try to match a specific token.
* @return Model|false
*/
- public function exists(User $user, $token = null)
- {
+ public function exists(User $user, $token = NULL) {
$model = $this->classMapper
->staticMethod($this->modelIdentifier, 'where', 'user_id', $user->id)
- ->where('completed', false)
+ ->where('completed', FALSE)
->where('expires_at', '>', Carbon::now());
if ($token) {
@@ -173,17 +169,16 @@ abstract class TokenRepository
$model->where('hash', $hash);
}
- return $model->first() ?: false;
+ return $model->first() ?: FALSE;
}
/**
* Delete all existing tokens from the database for a particular user.
*
- * @param User $user
+ * @param User $user
* @return int
*/
- protected function removeExisting(User $user)
- {
+ protected function removeExisting(User $user) {
return $this->classMapper
->staticMethod($this->modelIdentifier, 'where', 'user_id', $user->id)
->delete();
@@ -194,10 +189,9 @@ abstract class TokenRepository
*
* @return bool|null
*/
- public function removeExpired()
- {
+ public function removeExpired() {
return $this->classMapper
- ->staticMethod($this->modelIdentifier, 'where', 'completed', false)
+ ->staticMethod($this->modelIdentifier, 'where', 'completed', FALSE)
->where('expires_at', '<', Carbon::now())
->delete();
}
@@ -209,11 +203,10 @@ abstract class TokenRepository
* @param string $gen specify an existing token that, if we happen to generate the same value, we should regenerate on.
* @return string
*/
- protected function generateRandomToken($gen = null)
- {
+ protected function generateRandomToken($gen = NULL) {
do {
- $gen = md5(uniqid(mt_rand(), false));
- } while($this->classMapper
+ $gen = md5(uniqid(mt_rand(), FALSE));
+ } while ($this->classMapper
->staticMethod($this->modelIdentifier, 'where', 'hash', hash($this->algorithm, $gen))
->first());
return $gen;
diff --git a/main/app/sprinkles/account/src/Repository/VerificationRepository.php b/main/app/sprinkles/account/src/Repository/VerificationRepository.php
index b0cf048..405efc5 100644
--- a/main/app/sprinkles/account/src/Repository/VerificationRepository.php
+++ b/main/app/sprinkles/account/src/Repository/VerificationRepository.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Repository;
/**
@@ -23,8 +24,7 @@ class VerificationRepository extends TokenRepository
/**
* {@inheritDoc}
*/
- protected function updateUser($user, $args)
- {
+ protected function updateUser($user, $args) {
$user->flag_verified = 1;
// TODO: generate user activity? or do this in controller?
$user->save();
diff --git a/main/app/sprinkles/account/src/ServicesProvider/ServicesProvider.php b/main/app/sprinkles/account/src/ServicesProvider/ServicesProvider.php
index 4c3ab15..5c1bf20 100644
--- a/main/app/sprinkles/account/src/ServicesProvider/ServicesProvider.php
+++ b/main/app/sprinkles/account/src/ServicesProvider/ServicesProvider.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\ServicesProvider;
use Birke\Rememberme\Authenticator as RememberMe;
@@ -40,8 +41,7 @@ class ServicesProvider
*
* @param Container $container A DI container implementing ArrayAccess and container-interop.
*/
- public function register($container)
- {
+ public function register($container) {
/**
* Extend the asset manager service to see assets for the current user's theme.
*/
@@ -192,11 +192,11 @@ class ServicesProvider
$container['authLogger'] = function ($c) {
$logger = new Logger('auth');
- $logFile = $c->get('locator')->findResource('log://userfrosting.log', true, true);
+ $logFile = $c->get('locator')->findResource('log://userfrosting.log', TRUE, TRUE);
$handler = new StreamHandler($logFile);
- $formatter = new MixedFormatter(null, null, true);
+ $formatter = new MixedFormatter(NULL, NULL, TRUE);
$handler->setFormatter($formatter);
$logger->pushHandler($handler);
@@ -219,7 +219,7 @@ class ServicesProvider
* @return bool returns true no matter what.
*/
'always' => function () {
- return true;
+ return TRUE;
},
/**
@@ -240,10 +240,10 @@ class ServicesProvider
*/
'equals_num' => function ($val1, $val2) {
if (!is_numeric($val1)) {
- return false;
+ return FALSE;
}
if (!is_numeric($val2)) {
- return false;
+ return FALSE;
}
return ($val1 == $val2);
@@ -258,9 +258,9 @@ class ServicesProvider
*/
'has_role' => function ($user_id, $role_id) {
return Capsule::table('role_users')
- ->where('user_id', $user_id)
- ->where('role_id', $role_id)
- ->count() > 0;
+ ->where('user_id', $user_id)
+ ->where('role_id', $role_id)
+ ->count() > 0;
},
/**
@@ -347,14 +347,14 @@ class ServicesProvider
* This method is invoked when a user attempts to perform certain public actions when they are already logged in.
*
* @todo Forward to user's landing page or last visited page
- * @param \Psr\Http\Message\ServerRequestInterface $request
- * @param \Psr\Http\Message\ResponseInterface $response
+ * @param \Psr\Http\Message\ServerRequestInterface $request
+ * @param \Psr\Http\Message\ResponseInterface $response
* @param array $args
* @return \Psr\Http\Message\ResponseInterface
*/
return function (Request $request, Response $response, array $args) use ($c) {
$redirect = $c->router->pathFor('dashboard');
-
+
return $response->withRedirect($redirect, 302);
};
};
@@ -367,8 +367,8 @@ class ServicesProvider
* This method is invoked when a user completes the login process.
*
* Returns a callback that handles setting the `UF-Redirect` header after a successful login.
- * @param \Psr\Http\Message\ServerRequestInterface $request
- * @param \Psr\Http\Message\ResponseInterface $response
+ * @param \Psr\Http\Message\ServerRequestInterface $request
+ * @param \Psr\Http\Message\ResponseInterface $response
* @param array $args
* @return \Psr\Http\Message\ResponseInterface
*/
@@ -376,7 +376,7 @@ class ServicesProvider
// Backwards compatibility for the deprecated determineRedirectOnLogin service
if ($c->has('determineRedirectOnLogin')) {
$determineRedirectOnLogin = $c->determineRedirectOnLogin;
-
+
return $determineRedirectOnLogin($response)->withStatus(200);
}
diff --git a/main/app/sprinkles/account/src/Twig/AccountExtension.php b/main/app/sprinkles/account/src/Twig/AccountExtension.php
index 12bacba..287f879 100644
--- a/main/app/sprinkles/account/src/Twig/AccountExtension.php
+++ b/main/app/sprinkles/account/src/Twig/AccountExtension.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Twig;
use Interop\Container\ContainerInterface;
@@ -22,19 +23,16 @@ class AccountExtension extends \Twig_Extension implements \Twig_Extension_Global
protected $services;
protected $config;
- public function __construct(ContainerInterface $services)
- {
+ public function __construct(ContainerInterface $services) {
$this->services = $services;
$this->config = $services->config;
}
- public function getName()
- {
+ public function getName() {
return 'userfrosting/account';
}
- public function getFunctions()
- {
+ public function getFunctions() {
return array(
// Add Twig function for checking permissions during dynamic menu rendering
new \Twig_SimpleFunction('checkAccess', function ($slug, $params = []) {
@@ -50,16 +48,15 @@ class AccountExtension extends \Twig_Extension implements \Twig_Extension_Global
);
}
- public function getGlobals()
- {
+ public function getGlobals() {
try {
$currentUser = $this->services->currentUser;
} catch (\Exception $e) {
- $currentUser = null;
+ $currentUser = NULL;
}
return [
- 'current_user' => $currentUser
+ 'current_user' => $currentUser
];
}
}
diff --git a/main/app/sprinkles/account/src/Util/HashFailedException.php b/main/app/sprinkles/account/src/Util/HashFailedException.php
index a0b37d1..765096b 100644
--- a/main/app/sprinkles/account/src/Util/HashFailedException.php
+++ b/main/app/sprinkles/account/src/Util/HashFailedException.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Util;
use UserFrosting\Support\Exception\HttpException;
diff --git a/main/app/sprinkles/account/src/Util/Util.php b/main/app/sprinkles/account/src/Util/Util.php
index 6452990..f8a0444 100644
--- a/main/app/sprinkles/account/src/Util/Util.php
+++ b/main/app/sprinkles/account/src/Util/Util.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Account\Util;
use UserFrosting\Sprinkle\Core\Util\Util as CoreUtil;
@@ -21,8 +22,7 @@ class Util
/**
* Generate a random, unique username from a list of adjectives and nouns.
*/
- static public function randomUniqueUsername($classMapper, $maxLength, $maxTries = 10)
- {
+ static public function randomUniqueUsername($classMapper, $maxLength, $maxTries = 10) {
for ($n = 1; $n <= 3; $n++) {
for ($m = 0; $m < 10; $m++) {
// Generate a random phrase with $n adjectives