Ejemplo n.º 1
0
            // delete
            Route::delete('{id}', array("as" => "groups.destroy", "uses" => "Agkunz\\User\\GroupController@destroy"));
        });
    });
    // jesus please dear god don't use this
    Route::get("reset", array("as" => "dev.api.reset", "uses" => "Agkunz\\Api\\ApiController@reset"));
    // this is a work route to get your hmac
    Route::get('{email}', function ($email) {
        $key = Sentry::findUserByLogin($email)->getApiKey();
        $data = array('email' => $email, 'timestamp' => time());
        $hash_string = json_encode($data);
        $hmac = hash_hmac('sha256', $hash_string, $key);
        $data['hmac'] = $hmac;
        dd($data);
    });
});
Route::filter('apiauth', function () {
    if (!Api::authenticate()) {
        return Api::response(false);
    }
});
Route::filter('byroute', function () {
    if ($user = Config::get('user')) {
        if (!$user->hasPermission("superuser")) {
            if (!$user->hasPermission(Route::getCurrentRoute())) {
                MessageBag::add("error", "You don't have permission to use this route.");
                return Api::response(false);
            }
        }
    }
});
Ejemplo n.º 2
0
 /**
  * Update the specified resource in storage.
  *
  * @return Response
  */
 public function update($id)
 {
     $data = Input::all();
     if (isset($data['_method'])) {
         unset($data['_method']);
     }
     try {
         $response = $this->api->put($this->package . "/" . $id, $data);
     } catch (ApiException $e) {
         $errors = new MessageBag();
         $messages = $e->getMessages();
         foreach ($messages[0] as $key => $value) {
             foreach ($value as $msg) {
                 $errors->add($key, $msg);
             }
         }
         return Redirect::to("{$this->cmsAdminUrl}/{$this->package}/" . $id)->withErrors($errors);
     }
     return Redirect::to("{$this->cmsAdminUrl}/{$this->package}")->with('success', 'The data successfully saved!');
 }
Ejemplo n.º 3
0
 /**
  * @test
  */
 public function it_manages_messages()
 {
     $bag = new MessageBag();
     // Assert that there are no messages in the bag.
     $this->assertCount(0, $bag->getAll());
     // Add a bunch of them.
     $bag->throwIn($first = $this->createMessage(Message::NORMAL));
     $bag->throwIn($this->createMessage(Message::WARNING));
     $bag->throwIn($last = $this->createMessage(Message::ERROR));
     // Make sure it gets updated.
     $this->assertCount(3, $bag->getAll());
     // Test various getters.
     $this->assertCount(1, $bag->getNormalMessages());
     $this->assertCount(1, $bag->getWarnings());
     $this->assertCount(1, $bag->getErrors());
     // And these two as well.
     $this->assertEquals($bag->first(), $first);
     $this->assertEquals($bag->last(), $last);
 }