This is why git rebase is a horrible horrible thing.

This commit is contained in:
Kekskurse 2019-07-17 19:21:15 +02:00
parent 23d00a49f4
commit 2076182bd6
2 changed files with 33 additions and 3 deletions

View file

@ -12,19 +12,48 @@ use App\Http\Resources\API\AppForOwner;
use App\Http\Resources\API\AppUser; use App\Http\Resources\API\AppUser;
use App\Models\Setting; use App\Models\Setting;
use App\Models\User; use App\Models\User;
use http\Env\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Laravel\Lumen\Routing\Controller as BaseController; use Laravel\Lumen\Routing\Controller as BaseController;
use TaGeSo\APIResponse\Response; use TaGeSo\APIResponse\Response;
class AppController extends BaseController class AppController extends BaseController
{ {
public function listApps(Response $response) { public function createApp(Request $request, Response $response) {
if(!Auth::check()) { if(!Auth::check()) {
throw new NotLoggedInException(); throw new NotLoggedInException();
} }
if(!app('currentAccess')->getApp()->access_read_apps) { if (!Auth::user()->developer) {
throw new NoPermissionException(403, "You need a developer Account to create new Apps.");
}
if (!app('currentAccess')->getApp()->access_update_apps) {
throw new NoPermissionException(403, "App has no access to perform this request.");
}
$this->validate($request, [
'name' => 'required|max:255|min:3|regex:@^[a-zA-Z0-9]*$@|unique:apps',
'description' => 'required|min:3',
'url' => 'required|url'
]);
$app = \App\Models\App::createApp($request->input("name"), htmlspecialchars($request->input("description")), $request->input("url"), Auth::user());
return $response->withData(new AppForOwner($app));
}
public function listApps(Response $response) {
if (!Auth::check()) {
throw new NotLoggedInException();
}
if (!Auth::user()->developer) {
throw new NoPermissionException(403, "You need a developer Account to create new Apps.");
}
if (!app('currentAccess')->getApp()->access_read_apps) {
throw new NoPermissionException(403, "App has no access to perform this request."); throw new NoPermissionException(403, "App has no access to perform this request.");
} }

View file

@ -48,6 +48,7 @@ $router->group(['prefix' => 'api'], function () use ($router) {
}); });
$router->group(['prefix' => 'app'], function () use ($router) { $router->group(['prefix' => 'app'], function () use ($router) {
$router->get("/", ['uses' => 'API\AppController@listApps']); $router->get("/", ['uses' => 'API\AppController@listApps']);
$router->post("/", ['uses' => 'API\AppController@createApp']);
$router->get("/find", ['uses' => 'API\AppController@findApp']); $router->get("/find", ['uses' => 'API\AppController@findApp']);
$router->group(['prefix' => '{id}'], function () use ($router) { $router->group(['prefix' => '{id}'], function () use ($router) {
$router->get("/", ['uses' => 'API\AppController@appDetails']); $router->get("/", ['uses' => 'API\AppController@appDetails']);