public function action_index() { $auth_user_lookup_result = FALSE; // Handle Post and show success message if (count($this->request->post())) { $valid = TRUE; $data = new stdClass(); $data->id = Session::instance()->get('auth_uid'); $data->name = $this->request->post('name'); $data->email = $this->request->post('email'); if ($this->request->post('current_password') or $this->request->post('new_password') or $this->request->post('repeat_password')) { if (!strlen($this->request->post('current_password')) or !strlen($this->request->post('new_password')) or !strlen($this->request->post('repeat_password'))) { $this->_view->send_error_message('Please include all password fields.'); $valid = FALSE; } else { if ($this->request->post('new_password') != $this->request->post('repeat_password')) { $this->_view->send_error_message('Those new passwords did not match.'); $valid = FALSE; } else { $data->current_password = $this->request->post('current_password'); $data->password = $this->request->post('new_password'); } } } if ($valid) { $auth_user_update = new Beans_Auth_User_Update($this->_beans_data_auth($data)); $auth_user_update_result = $auth_user_update->execute(); if (!$auth_user_update_result->success) { $this->_view->send_error_message($auth_user_update_result->error . $auth_user_update_result->auth_error); } else { $this->_view->send_success_message('Your account was updated.'); $auth_user_lookup_result = $auth_user_update_result; } } } if (!$auth_user_lookup_result) { $auth_user_lookup = new Beans_Auth_User_Lookup($this->_beans_data_auth((object) array('id' => Session::instance()->get('auth_uid')))); $auth_user_lookup_result = $auth_user_lookup->execute(); } $this->_view->auth_user_lookup_result = $auth_user_lookup_result; }
public function action_apiregen() { $user_id = $this->request->post('auth_uid'); $random_password = $this->_generate_random_string(); // Create User $auth_user_update = new Beans_Auth_User_Update($this->_beans_data_auth((object) array('id' => $user_id, 'password' => $random_password))); $auth_user_update_result = $auth_user_update->execute(); if (!$auth_user_update_result->success) { return $this->_return_error($this->_beans_result_get_error($auth_user_update_result)); } $auth_login = new Beans_Auth_Login((object) array('email' => $auth_user_update_result->data->user->email, 'password' => $random_password)); $auth_login_result = $auth_login->execute(); if (!$auth_login_result->success) { return $this->_return_error($this->_beans_result_get_error($auth_login_result)); } $html = new View_Partials_Setup_Users_Api(); $html->auth = $auth_login_result->data->auth; $auth_login_result->data->auth->html = $html->render(); $this->_return_object->data->auth = $auth_login_result->data->auth; }