function action_index() { // Check and make sure Beans is setup. $setup_check = new Beans(); $setup_check_result = $setup_check->execute(); if (!$setup_check_result->success && isset($setup_check_result->config_error) && strpos(strtolower($setup_check_result->config_error), 'update') !== FALSE) { $this->request->redirect('/update'); } else { if (!$setup_check_result->success) { $this->request->redirect('/install'); } } if (count($this->request->post())) { $auth_login = new Beans_Auth_Login((object) array('email' => $this->request->post('email'), 'password' => $this->request->post('password'))); $auth_login_result = $auth_login->execute(); if ($this->_beans_result_check($auth_login_result)) { if (isset($auth_login_result->data->reset)) { $this->request->redirect('/auth/reset/' . $auth_login_result->data->reset); } Session::instance()->set('auth_uid', $auth_login_result->data->auth->auth_uid); Session::instance()->set('auth_expiration', $auth_login_result->data->auth->auth_expiration); Session::instance()->set('auth_key', $auth_login_result->data->auth->auth_key); Session::instance()->set('auth_role', $auth_login_result->data->auth->user->role); $this->request->redirect('/'); } } }
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; }