aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php6
-rw-r--r--src/controllers/UserController.php1
-rw-r--r--src/routes.php46
3 files changed, 30 insertions, 23 deletions
diff --git a/src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php b/src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php
index 6351614..104837b 100644
--- a/src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php
+++ b/src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php
@@ -54,6 +54,12 @@ class BotleaguesApiServiceProvider extends ServiceProvider {
],
500);
});
+ API::error(function(Exception\LoginException $e) {
+ $response = Response::make('', 401);
+ $response->header('WWW-Authenticate', 'Basic realm="Please login:"');
+
+ return $response;
+ });
API::error(function(\Exception $e) {
return Response::make(
['error' => Config::get('app.debug') ? $e->getMessage() : "Internal error"],
diff --git a/src/controllers/UserController.php b/src/controllers/UserController.php
index 5c247fb..9f914c6 100644
--- a/src/controllers/UserController.php
+++ b/src/controllers/UserController.php
@@ -25,6 +25,7 @@ class UserController extends BaseController {
}
public function login() {
+ Auth::basic();
return Auth::user();
}
diff --git a/src/routes.php b/src/routes.php
index 9b3266b..027603c 100644
--- a/src/routes.php
+++ b/src/routes.php
@@ -1,6 +1,29 @@
<?php
Route::group(array('https'), function() {
+ Route::api(['version' => 'v1', 'protected' => false], function () {
+
+ Route::get('user/login', 'CamilStaps\BotleaguesApi\UserController@login');
+ Route::resource('bot', 'CamilStaps\BotleaguesApi\BotController',
+ ['only' => ['index','show']]);
+
+ Route::resource('competition', 'CamilStaps\BotleaguesApi\CompetitionController',
+ ['only' => ['index','show']]);
+
+ Route::resource('competition_type', 'CamilStaps\BotleaguesApi\CompetitionTypeController',
+ ['only' => ['index','show']]);
+
+ Route::resource('game', 'CamilStaps\BotleaguesApi\GameController',
+ ['only' => ['index','show']]);
+
+ Route::resource('participant', 'CamilStaps\BotleaguesApi\ParticipantController',
+ ['only' => ['index','show']]);
+
+ Route::resource('user', 'CamilStaps\BotleaguesApi\UserController',
+ ['only' => ['index','show','store']]);
+
+ });
+
Route::api(['version' => 'v1', 'protected' => true, 'providers' => 'basic'], function () {
Route::resource('bot', 'CamilStaps\BotleaguesApi\BotController',
@@ -8,7 +31,6 @@ Route::group(array('https'), function() {
Route::resource('user', 'CamilStaps\BotleaguesApi\UserController',
['except' => ['index', 'show', 'create','edit','store']]);
- Route::get('user/login', 'CamilStaps\BotleaguesApi\UserController@login');
Route::group(array('before' => 'administrator'), function() {
@@ -25,26 +47,4 @@ Route::group(array('https'), function() {
});
- Route::api(['version' => 'v1', 'protected' => false], function () {
-
- Route::resource('bot', 'CamilStaps\BotleaguesApi\BotController',
- ['only' => ['index','show']]);
-
- Route::resource('competition', 'CamilStaps\BotleaguesApi\CompetitionController',
- ['only' => ['index','show']]);
-
- Route::resource('competition_type', 'CamilStaps\BotleaguesApi\CompetitionTypeController',
- ['only' => ['index','show']]);
-
- Route::resource('game', 'CamilStaps\BotleaguesApi\GameController',
- ['only' => ['index','show']]);
-
- Route::resource('participant', 'CamilStaps\BotleaguesApi\ParticipantController',
- ['only' => ['index','show']]);
-
- Route::resource('user', 'CamilStaps\BotleaguesApi\UserController',
- ['only' => ['index','show','store']]);
-
- });
-
}); \ No newline at end of file