当前位置: 首页>>代码示例>>PHP>>正文


PHP User_Model::create_user方法代码示例

本文整理汇总了PHP中User_Model::create_user方法的典型用法代码示例。如果您正苦于以下问题:PHP User_Model::create_user方法的具体用法?PHP User_Model::create_user怎么用?PHP User_Model::create_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在User_Model的用法示例。


在下文中一共展示了User_Model::create_user方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: token

 public function token()
 {
     if ($this->get_method() != 'POST') {
         $this->send_response(405, NULL, '请求的方法不存在');
     }
     $data = $this->get_data();
     $zone_code = isset($data['zone_code']) ? $data['zone_code'] : '';
     $mobile = isset($data['mobile']) ? $data['mobile'] : '';
     $code = isset($data['code']) ? $data['code'] : '';
     if (!international::check_is_valid($zone_code, $mobile)) {
         $this->send_response(400, NULL, Kohana::lang('authorization.mobile_invalid'));
     }
     $username = $this->model->get_full_mobile($zone_code, $mobile);
     if (!$this->is_test_mobile($mobile)) {
         if (!$this->model->check_verify_code($username, $code)) {
             $this->send_response(400, NULL, Kohana::lang('authorization.code_invalid'));
         }
     }
     $user = $this->model->get_user_by_mobile($zone_code, $mobile);
     if ($user) {
         $id = $user['id'];
     } else {
         $regip = $this->get_ip();
         $id = $this->model->create_user($zone_code, $mobile, '', $regip);
     }
     $token = $this->model->create_token(3600, TRUE, array('zone_code' => $zone_code, 'mobile' => $mobile, 'id' => (int) $id));
     if ($user) {
         $token['name'] = $user['username'];
         $token['avatar'] = sns::getavatar($user['id']);
     }
     $this->send_response(200, $token);
 }
开发者ID:momoim,项目名称:momo-api,代码行数:32,代码来源:auth.php

示例2: login_riverid

 /**
  * Logs a user in using the RiverID method.
  *
  * @param   string   username
  * @param   string   password
  * @param   boolean  enable auto-login
  * @param   string   email
  * @param   object   a riverid object, not required
  * @return  boolean
  */
 public function login_riverid($user, $password, $remember, $email, $riverid = false)
 {
     // First check for exemptions
     if (!is_object($user)) {
         // Load the user
         $user = ORM::factory('user', $user);
     }
     if (isset($user->id) and in_array($user->id, kohana::config('riverid.exempt'))) {
         // Looks like this is an exempted account
         return $this->login_standard($user, $password, $remember);
     }
     // Get down to business since there were no exemptions
     if ($riverid == false) {
         $riverid = new RiverID();
         $riverid->email = $email;
         $riverid->password = $password;
     }
     $is_registered = $riverid->is_registered();
     // See if the request even fired off.
     if ($riverid->error) {
         throw new Exception($riverid->error[0]);
     }
     if ($is_registered == true) {
         // RiverID is registered on RiverID Server
         if ($riverid->authenticated != true) {
             // Attempt to sign in if our riverid object hasn't already authenticated
             $riverid->signin();
         }
         if ($riverid->authenticated == true) {
             // Correct email/pass
             // Collect the RiverID user_id and connect that with a user in the local system
             $user = User_Model::get_user_by_river_id($riverid->user_id);
             if (!$user->id) {
                 // User not found locally with that RiverID, we need to see if they are already registered
                 //   and convert their account or add them as a new user to the system
                 // This may be a brand new user, but we need to figure out if
                 //    the email has already been registered
                 $user = User_Model::get_user_by_email($riverid->email);
                 if (!$user->id) {
                     // Email isn't in our system, create a new user.
                     $user = User_Model::create_user($riverid->email, $riverid->password, $riverid->user_id);
                 } else {
                     // Email already exists. Put the RiverID on that account.
                     $user->riverid = $riverid->user_id;
                     $user->save();
                 }
             } else {
                 // We authenticated and we matched a RiverID, lets just makes sure the email
                 //   addresses are both up to date
                 if ($user->email != $riverid->email) {
                     // We don't have a match for this user account. We need to see if we should
                     //   be updating this account by first checking to see if another account
                     //   already uses this email address
                     $user_check = User_Model::get_user_by_email($riverid->email);
                     if (!$user_check->id) {
                         $user->email = $riverid->email;
                         $user->username = $riverid->email;
                         $user->save();
                     } else {
                         // Conflicting accounts
                         // TODO: Figure out what to do when we need to update an email address on
                         //   one account but it's already in use on another.
                     }
                 }
             }
             // Now that we have our user account tied to their RiverID, approve their authentication
             return $this->perform_login($user, $remember, $riverid);
         } else {
             // Incorrect email/pass, but registered on RiverID. Failed login.
             if ($riverid->error) {
                 throw new Exception($riverid->error[0]);
             }
             return FALSE;
         }
     } else {
         // Email is not registerd on RiverID Server, could be registered locally
         // First see if they used the correct user/pass on their local account
         $user = User_Model::get_user_by_email($riverid->email);
         if (!$user->id) {
             // User doesn't exist locally or on RiverID. Fail login.
             if ($riverid->error) {
                 throw new Exception($riverid->error[0]);
             }
             return FALSE;
         } else {
             // User exists locally but doesn't yet exist on the RiverID server
             // Check if they got the password correct
             if ($user->has(ORM::factory('role', 'login')) and User_Model::check_password($user->id, $password, TRUE)) {
                 // Correct password! Create RiverID account
                 $riverid->register();
//.........这里部分代码省略.........
开发者ID:nemmy,项目名称:Ushahidi_Web,代码行数:101,代码来源:ORM.php

示例3: index


//.........这里部分代码省略.........
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             // We need to already have created an error message file, for Kohana to use
             // Pass the error message file name to the errors() method
             $errors = arr::merge($errors, $post->errors('auth'));
             $form_error = TRUE;
         }
         // END: Signin Process
     } elseif ($_POST and isset($_POST["action"]) and $_POST["action"] == "new") {
         // START: New User Process
         $post = Validation::factory($_POST);
         //	Add some filters
         $post->pre_filter('trim', TRUE);
         $post->add_rules('password', 'required', 'length[' . kohana::config('auth.password_length') . ']', 'alpha_dash');
         $post->add_rules('name', 'required', 'length[3,100]');
         $post->add_rules('email', 'required', 'email', 'length[4,64]');
         $post->add_callbacks('username', array($this, 'username_exists_chk'));
         $post->add_callbacks('email', array($this, 'email_exists_chk'));
         // If Password field is not blank
         if (!empty($post->password)) {
             $post->add_rules('password', 'required', 'length[' . kohana::config('auth.password_length') . ']', 'alpha_dash', 'matches[password_again]');
         }
         //pass the post object to any plugins that care to know.
         Event::run('ushahidi_action.users_add_login_form', $post);
         if ($post->validate()) {
             $riverid_id = false;
             if (kohana::config('riverid.enable') == true) {
                 $riverid = new RiverID();
                 $riverid->email = $post->email;
                 $riverid->password = $post->password;
                 $riverid->register();
                 $riverid_id = $riverid->user_id;
             }
             $user = User_Model::create_user($post->email, $post->password, $riverid_id, $post->name);
             //pass the new user on to any plugins that care to know
             Event::run('ushahidi_action.user_edit', $user);
             // Send Confirmation email
             $email_sent = $this->_send_email_confirmation($user);
             if ($email_sent) {
                 $message_class = 'login_success';
                 $message = Kohana::lang('ui_main.login_confirmation_sent');
             } else {
                 $message_class = 'login_success';
                 $message = Kohana::lang('ui_main.login_account_creation_successful');
             }
             $success = TRUE;
             $action = "";
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::merge($errors, $post->errors('auth'));
             $form_error = TRUE;
         }
         // END: New User Process
     } elseif ($_POST and isset($_POST["action"]) and $_POST["action"] == "forgot") {
         // START: Forgot Password Process
         $post = Validation::factory($_POST);
         //	Add some filters
         $post->pre_filter('trim', TRUE);
         $post->add_callbacks('resetemail', array($this, 'email_exists_chk'));
         if ($post->validate()) {
             $user = ORM::factory('user', $post->resetemail);
             // Existing User??
             if ($user->loaded) {
                 $email_sent = FALSE;
开发者ID:rjmackay,项目名称:Ushahidi_Web,代码行数:67,代码来源:login.php


注:本文中的User_Model::create_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。