aboutsummaryrefslogtreecommitdiffhomepage
path: root/main/app/sprinkles/admin/src/Controller/UserController.php
diff options
context:
space:
mode:
Diffstat (limited to 'main/app/sprinkles/admin/src/Controller/UserController.php')
-rw-r--r--main/app/sprinkles/admin/src/Controller/UserController.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/main/app/sprinkles/admin/src/Controller/UserController.php b/main/app/sprinkles/admin/src/Controller/UserController.php
index 46d0f0f..30a8d30 100644
--- a/main/app/sprinkles/admin/src/Controller/UserController.php
+++ b/main/app/sprinkles/admin/src/Controller/UserController.php
@@ -231,6 +231,32 @@ class UserController extends SimpleController
return $response->withStatus(200);
}
+
+ /**
+ * Sets the users public key
+ * Request type: POST
+ */
+ public function setPublicKey($request, $response, $args) {
+ $user = $this->getUserFromParams($args);
+
+ if (!$user) {
+ throw new NotFoundException($request, $response);
+ }
+
+ $classMapper = $this->ci->classMapper;
+ $requestedUser = $classMapper->staticMethod('user', 'where', 'user_name', $args['user_name'])
+ ->first();
+
+ if ($user->id === $requestedUser->id) {
+ $PublicKey = $request->getParsedBody()["PublicKey"];
+ Capsule::table('public_keys')
+ ->insert(['UserID' => $requestedUser->id, 'Key' => $PublicKey]);
+ return $response->withStatus(200);
+ } else {
+ throw new ForbiddenException();
+ }
+ }
+
/**
* Processes the request to delete an existing user.
*