public function get_with_access_key_test() { $key = rest::get_access_token(1); // admin user $_SERVER["REQUEST_METHOD"] = "GET"; $_SERVER["HTTP_X_GALLERY_REQUEST_KEY"] = $key->access_key; $_GET["key"] = "value"; $this->assert_array_equal_to_json(array("params" => array("key" => "value"), "method" => "get", "access_token" => $key->access_key, "url" => "http://./index.php/gallery_unit_test"), test::call_and_capture(array(new Rest_Controller(), "mock"))); }
public function index() { $username = Input::instance()->post("user"); $password = Input::instance()->post("password"); $user = identity::lookup_user_by_name($username); if (empty($user) || !identity::is_correct_password($user, $password)) { throw new Rest_Exception("Forbidden", 403); } $key = rest::get_access_token($user->id); rest::reply($key->access_key); }
public function index() { $username = Input::instance()->post("user"); $password = Input::instance()->post("password"); if (empty($username) || auth::too_many_failures($username)) { throw new Rest_Exception("Forbidden", 403); } $user = identity::lookup_user_by_name($username); if (empty($user) || !identity::is_correct_password($user, $password)) { module::event("user_login_failed", $username); throw new Rest_Exception("Forbidden", 403); } auth::login($user); $key = rest::get_access_token($user->id); rest::reply($key->access_key); }