API modifications

This commit is contained in:
Marcel Pociot
2021-06-01 20:26:23 +02:00
parent a29874e221
commit 5e54d0a80f
3 changed files with 26 additions and 6 deletions

View File

@@ -39,7 +39,8 @@ class StoreSubdomainController extends AdminController
return;
}
$this->userRepository->getUserByToken($request->get('auth_token', ''))
$this->userRepository
->getUserByToken($request->get('auth_token', ''))
->then(function ($user) use ($httpConnection, $request) {
if (is_null($user)) {
$httpConnection->send(respond_json(['error' => 'The user does not exist'], 404));
@@ -55,6 +56,13 @@ class StoreSubdomainController extends AdminController
return;
}
if (in_array($request->get('subdomain'), config('expose.admin.reserved_subdomains', []))) {
$httpConnection->send(respond_json(['error' => 'The subdomain is already taken.'], 422));
$httpConnection->close();
return;
}
$insertData = [
'user_id' => $user['id'],
'subdomain' => $request->get('subdomain'),