summaryrefslogtreecommitdiffstats
path: root/application/controllers/user.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2016-07-13 21:35:22 +0200
committerFlorian Pritz <bluewind@xinu.at>2016-07-13 21:35:22 +0200
commit7f012ee652e0c62c6b73bfa3fc029b7749520b6c (patch)
tree611cd96de0e0c0d623760d23425ea750386399de /application/controllers/user.php
parent13206d03280dc138583815984b7bde20e63bf94d (diff)
controllers/user: Deduplicate email verification
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/controllers/user.php')
-rw-r--r--application/controllers/user.php19
1 files changed, 14 insertions, 5 deletions
diff --git a/application/controllers/user.php b/application/controllers/user.php
index 4ff9ae530..e1c01051a 100644
--- a/application/controllers/user.php
+++ b/application/controllers/user.php
@@ -208,8 +208,7 @@ class User extends MY_Controller {
}
}
- $this->load->helper("email");
- if (!valid_email($email)) {
+ if (!$this->valid_email($email)) {
$error[]= "Invalid email.";
}
@@ -628,6 +627,18 @@ class User extends MY_Controller {
return !$username || strlen($username) > 32 || !preg_match("/^[a-z0-9]+$/", $username);
}
+ /**
+ * Check if a given email is valid. Only perform minimal checking since
+ * verifying emails is very very difficuly.
+ *
+ * @return boolean
+ */
+ private function valid_email($email)
+ {
+ $this->load->helper("email");
+ return valid_email($email);
+ }
+
function add_user()
{
if (!$this->input->is_cli_request()) return;
@@ -635,7 +646,6 @@ class User extends MY_Controller {
$error = array();
- // FIXME: deduplicate username/email verification with register()
$username = $this->_get_line_cli("Username", function($username) {
if (!$this->valid_username($username)) {
echo "Invalid username (only up to 32 chars of a-z0-9 are allowed).\n";
@@ -649,9 +659,8 @@ class User extends MY_Controller {
return true;
});
- $this->load->helper("email");
$email = $this->_get_line_cli("Email", function($email) {
- if (!valid_email($email)) {
+ if (!$this->valid_email($email)) {
echo "Invalid email.\n";
return false;
}