diff options
author | Marvin Borner | 2018-05-10 20:42:13 +0200 |
---|---|---|
committer | Marvin Borner | 2018-05-10 20:42:13 +0200 |
commit | a8d37fab30ccbced5ec8819510ee84893460bb5e (patch) | |
tree | d5983c82b866661c71d8683032ce303789847e29 /main/app/sprinkles/admin/src/Controller/UserController.php | |
parent | ef6fc62a5048afd8467af20b34861ad085566481 (diff) |
Began chat encrpytion integration and ECC key generation on registration
Diffstat (limited to 'main/app/sprinkles/admin/src/Controller/UserController.php')
-rw-r--r-- | main/app/sprinkles/admin/src/Controller/UserController.php | 26 |
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. * |