This commit is contained in:
Kekskurse 2019-11-26 17:52:26 +01:00
parent f3596ce761
commit aa4b623978
2 changed files with 18 additions and 0 deletions

View file

@ -145,4 +145,21 @@ class AdminController extends BaseController
return $response->withData($invites); return $response->withData($invites);
} }
public function inviteNew(Request $request, Response $response) {
if(!Auth::user()->admin) {
throw new HTTPException("Need Admin Access");
}
$invite = new Invite();
$invite->user_id = Auth::user()->id;
$invite->username = $request->input("username", null);
$invite->comment = $request->input("comment", null);
$invite->status = "active";
$invite->createToken();
$invite->saveOrFail();
return $response->withData($invite);
}
} }

View file

@ -93,6 +93,7 @@ $router->group(['prefix' => 'api'], function () use ($router) {
$router->put("/app/{id}/properties", ["uses" => "API\AdminController@saveAppProperties"]); $router->put("/app/{id}/properties", ["uses" => "API\AdminController@saveAppProperties"]);
$router->group(['prefix' => 'invite'], function () use ($router) { $router->group(['prefix' => 'invite'], function () use ($router) {
$router->get("", ["uses" => "API\AdminController@listInvites"]); $router->get("", ["uses" => "API\AdminController@listInvites"]);
$router->post("", ["uses" => "API\AdminController@inviteNew"]);
}); });
}); });
}); });