summaryrefslogtreecommitdiff
path: root/src/Controllers/KeyController.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Controllers/KeyController.php')
-rw-r--r--src/Controllers/KeyController.php10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Controllers/KeyController.php b/src/Controllers/KeyController.php
index b2a17a6..a8b4fb1 100644
--- a/src/Controllers/KeyController.php
+++ b/src/Controllers/KeyController.php
@@ -4,7 +4,9 @@ namespace App\Controllers;
use App\Errors\AppException;
use App\Errors\ErrorCode;
+use App\Errors\UnauthorizedError;
use App\Models\Tokens;
+use App\Models\User;
use App\Support\RequestValidator;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -27,11 +29,19 @@ class KeyController
*/
public function upload(Request $request): Response
{
+ $accessToken = str_replace("Bearer ", "", $request->headers->get("authorization") ?: "");
+ $user = User::fetchWithAccessToken($accessToken);
+
+ if (empty($user)) {
+ throw new UnauthorizedError();
+ }
+
$body = json_decode($request->getContent(), true);
RequestValidator::validateJson();
return new JsonResponse([
"one_time_key_counts" => [
+ "curve25519" => 0,
"signed_curve25519" => count($body["one_time_keys"])
],
]);