validate user response

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2017-10-19 14:05:02 +02:00 committed by Morris Jobke
parent 8b01176f60
commit 78a24e3b81
No known key found for this signature in database
GPG key ID: FE03C3A163FEDE68

View file

@ -70,7 +70,14 @@ class OCS extends ApiBase implements ICapabilitiesApi, IUserApi {
}
public function getUser($userId) {
return new User($this->request('get', 'cloud/users/' . $userId));
$result = $this->request('get', 'cloud/users/' . $userId);
$keys = ['id', 'email', 'displayname', 'phone', 'address', 'website', 'groups', 'language', 'quota'];
foreach ($keys as $key) {
if (!isset($result[$key])) {
throw new \Exception('Invalid user response, expected field ' . $key . ' not found');
}
}
return new User($result);
}
/**