summaryrefslogtreecommitdiffstats
path: root/application/models/muser.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2016-07-14 15:16:34 +0200
committerFlorian Pritz <bluewind@xinu.at>2016-07-14 15:16:34 +0200
commit1b462fac46eaf387f47a274a9f6bd9b46cd19981 (patch)
tree660fab7226d65668ca64bd1643391594cd50cf04 /application/models/muser.php
parent449302a0ac3c9f5127d098927939cf14da3eaa92 (diff)
Move username/email validation functions to muser
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/models/muser.php')
-rw-r--r--application/models/muser.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/application/models/muser.php b/application/models/muser.php
index f2b961d89..4ec821f4d 100644
--- a/application/models/muser.php
+++ b/application/models/muser.php
@@ -134,6 +134,31 @@ class Muser extends CI_Model {
return $this->session->userdata('username');
}
+ /*
+ * Check if a given username is valid.
+ *
+ * Valid usernames contain only lowercase characters and numbers. They are
+ * also <= 32 characters in length.
+ *
+ * @return boolean
+ */
+ public function valid_username($username)
+ {
+ return 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
+ */
+ public function valid_email($email)
+ {
+ $this->load->helper("email");
+ return valid_email($email);
+ }
+
function get_userid()
{
if (!$this->logged_in()) {