summaryrefslogtreecommitdiffstats
path: root/application/controllers/user.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2012-12-16 13:12:57 +0100
committerFlorian Pritz <bluewind@xinu.at>2012-12-16 13:12:57 +0100
commita83ceb1791676b9d7e8659760be570895706ac2c (patch)
tree5ee5c62bde62a969cec44a28cbc756e8d4b56056 /application/controllers/user.php
parent5659e23cd8c928bd26dff16b13b0eebf89688bef (diff)
c/user: register() prevent DB error if username is non-ascii
The DB col is set to ascii_general_ci so if the username doesn't pass the charset check we shouldn't even bother query the db because that can trigger a collation error (utf-8 vs ascii). Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/controllers/user.php')
-rw-r--r--application/controllers/user.php8
1 files changed, 4 insertions, 4 deletions
diff --git a/application/controllers/user.php b/application/controllers/user.php
index aa1ea235b..cac47ebe1 100644
--- a/application/controllers/user.php
+++ b/application/controllers/user.php
@@ -142,6 +142,10 @@ class User extends CI_Controller {
if (!$username || strlen($username) > 32 || !preg_match("/^[a-z0-9]+$/", $username)) {
$error[]= "Invalid username (only up to 32 chars of a-z0-9 are allowed).";
+ } else {
+ if ($this->muser->username_exists($username)) {
+ $error[] = "Username already exists.";
+ }
}
$this->load->helper("email");
@@ -149,10 +153,6 @@ class User extends CI_Controller {
$error[]= "Invalid email.";
}
- if ($this->muser->username_exists($username)) {
- $error[] = "Username already exists.";
- }
-
if (!$password || $password != $password_confirm) {
$error[]= "No password or passwords don't match.";
}