summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcanyonknight <canyonknight@gmail.com>2013-01-22 23:15:35 +0100
committerLukas Fleischer <archlinux@cryptocrack.de>2013-01-30 09:25:29 +0100
commit1fd620cc2fc93b238af6793a9970f5a79f6ed7a3 (patch)
treea2fe2afed342eb2466f979f456dd3cc11f799eab
parenta61d73d804d615b555fdccbec669f8e2cf84217d (diff)
downloadaur-1fd620cc2fc93b238af6793a9970f5a79f6ed7a3.tar.gz
aur-1fd620cc2fc93b238af6793a9970f5a79f6ed7a3.tar.xz
acctfuncs.inc.php: Change return type of valid_username function
The function is only determining whether a username is valid, so it makes more sense to simply return a boolean value. Signed-off-by: canyonknight <canyonknight@gmail.com> Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
-rw-r--r--web/lib/acctfuncs.inc.php11
1 files changed, 5 insertions, 6 deletions
diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php
index a41659ee..cdf4af6f 100644
--- a/web/lib/acctfuncs.inc.php
+++ b/web/lib/acctfuncs.inc.php
@@ -480,12 +480,12 @@ function try_login($dbh=NULL) {
*
* The username must be longer or equal to USERNAME_MIN_LEN. It must be shorter
* or equal to USERNAME_MAX_LEN. It must start and end with either a letter or
- * a number. It can contain one period, hypen, or underscore. Returns username
- * if it meets all of those rules.
+ * a number. It can contain one period, hypen, or underscore. Returns boolean
+ * of whether name is valid.
*
* @param string $user Username to validate
*
- * @return string|void Return username if it meets criteria, otherwise void
+ * @return bool True if username meets criteria, otherwise false
*/
function valid_username($user) {
if (!empty($user)) {
@@ -500,13 +500,12 @@ function valid_username($user) {
# contain only letters and numbers,
# and at most has one dash, period, or underscore
if ( preg_match("/^[a-z0-9]+[.\-_]?[a-z0-9]+$/", $user) ) {
- #All is good return the username
- return $user;
+ return true;
}
}
}
- return;
+ return false;
}
/**