public function create() { if (Input::exists()) { $username = Input::get('username'); $password = Input::get('password'); $org = Input::get('org'); $email = Input::get('email'); $role = Input::get('user_type'); $validate = Validator::load(DB::load()); $validation = $validate->checkPost($_POST, array('username' => array('required' => true, 'min' => 3, 'max' => 32, 'notTaken' => 'Users'), 'full_name' => array('required' => true, 'min' => 3, 'max' => 50), 'password' => array('required' => true, 'min' => 3, 'max' => 32, 'validPass' => $password), 'email' => array('required' => true, 'min' => 3, 'max' => 32, 'validEmail' => $email))); if ($validation->passed()) { DB::load()->insert('Users', array('Created' => time(), 'Username' => $username, 'Password' => Password::hash($password), 'Email' => $email, 'Name' => Input::get('full_name'), 'Org' => $org, 'Role_ID' => $role, 'Status_ID' => 2, 'Auth_token' => Token::create(46))); Session::set('SUCCESS', I18n::get('AUTH_CREATE_SUCCESS')); Redirect::to($this->data['project_url'] . 'login#form'); } else { // gather the errorrs and echo them out foreach ($validation->errors() as $error) { $_SESSION['ERRORS'][] = $error; } Redirect::to($this->data['project_url'] . 'login#form'); } } }
public function resetToken($user_id) { $token = Token::create(46); $this->search($user_id); $this->db->update($this->users, 'ID', $user_id, array('Reset_token' => $token)); return $token; }