Exemple #1
0
 public static function validateEmail($email, $type)
 {
     $email_name = substr($email, 0, strpos($email, '@'));
     if (preg_match('/[^A-Za-z0-9\\-\\_\\.]+/', $email_name)) {
         throw new AuthCheckException('email', 'auth.email.email');
     }
     if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
         throw new AuthCheckException('email', 'email is not valid');
     }
     if ($type != "login") {
         $query = array('email' => new \MongoRegex('/' . $email . '$/i'));
         $user = UsersModel::where($query)->first();
         if ($user) {
             throw new AuthCheckException('email', 'auth.email.exist');
         }
     }
     return true;
 }
Exemple #2
0
 public static function isExists(array $data)
 {
     $required_fields = array('field', 'value');
     $field = $data['field'];
     $value = $data['value'];
     $query = array($field => $value);
     $user_info = UsersModel::where($query)->first();
     $result = empty($user_info) ? false : true;
     return $result;
 }