validate user response
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
8b01176f60
commit
78a24e3b81
1 changed files with 8 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue