Browse Source
Add endpoint to set the password
Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/402/head
Joas Schilling
8 years ago
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
2 changed files with
38 additions and
0 deletions
-
appinfo/routes.php
-
lib/Controller/RoomController.php
|
|
|
@ -139,6 +139,15 @@ return [ |
|
|
|
'token' => '^[a-z0-9]{4,30}$', |
|
|
|
], |
|
|
|
], |
|
|
|
[ |
|
|
|
'name' => 'Room#setPassword', |
|
|
|
'url' => '/api/{apiVersion}/room/{token}/password', |
|
|
|
'verb' => 'PUT', |
|
|
|
'requirements' => [ |
|
|
|
'apiVersion' => 'v1', |
|
|
|
'token' => '^[a-z0-9]{4,30}$', |
|
|
|
], |
|
|
|
], |
|
|
|
[ |
|
|
|
'name' => 'Room#getParticipants', |
|
|
|
'url' => '/api/{apiVersion}/room/{token}/participants', |
|
|
|
|
|
|
|
@ -675,6 +675,35 @@ class RoomController extends OCSController { |
|
|
|
return new DataResponse(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @NoAdminRequired |
|
|
|
* |
|
|
|
* @param string $token |
|
|
|
* @param string $password |
|
|
|
* @return DataResponse |
|
|
|
*/ |
|
|
|
public function setPassword($token, $password) { |
|
|
|
try { |
|
|
|
$room = $this->manager->getRoomForParticipantByToken($token, $this->userId); |
|
|
|
$participant = $room->getParticipant($this->userId); |
|
|
|
} catch (RoomNotFoundException $e) { |
|
|
|
return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
|
|
} catch (\RuntimeException $e) { |
|
|
|
return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
|
|
} |
|
|
|
|
|
|
|
if (!in_array($participant->getParticipantType(), [Participant::OWNER, Participant::MODERATOR], true)) { |
|
|
|
return new DataResponse([], Http::STATUS_FORBIDDEN); |
|
|
|
} |
|
|
|
|
|
|
|
if ($room->getType() !== Room::PUBLIC_CALL) { |
|
|
|
return new DataResponse([], Http::STATUS_FORBIDDEN); |
|
|
|
} |
|
|
|
|
|
|
|
$room->setPassword($password); |
|
|
|
return new DataResponse(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @NoAdminRequired |
|
|
|
* |
|
|
|
|