示例#1
0
 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);
     rest::reply(rest::access_key());
 }
示例#2
0
 public function delete_test()
 {
     $_SERVER["REQUEST_METHOD"] = "POST";
     $_SERVER["HTTP_X_GALLERY_REQUEST_METHOD"] = "delete";
     $_POST["key"] = "value";
     $this->assert_array_equal_to_json(array("params" => array("key" => "value"), "method" => "delete", "access_key" => rest::access_key(), "url" => "http://./index.php/gallery_unit_test"), test::call_and_capture(array(new Rest_Controller(), "mock")));
 }
示例#3
0
 static function reset_access_key()
 {
     $key = ORM::factory("user_access_key")->where("user_id", "=", identity::active_user()->id)->find();
     if ($key->loaded()) {
         $key->delete();
     }
     return rest::access_key();
 }