Check interface support on auth backend before attempting calls
This commit is contained in:
@@ -80,16 +80,28 @@ class SihnonFramework_Auth {
|
||||
*/
|
||||
|
||||
public function addUser($username, $password) {
|
||||
if ( ! is_subclass_of($this->backend, 'SihnonFramework_Auth_IUpdateable')) {
|
||||
throw new SihnonFramework_Exception_NotImplemented();
|
||||
}
|
||||
|
||||
return $this->backend->addUser($username, $password);
|
||||
}
|
||||
|
||||
public function removeUser() {
|
||||
if ( ! is_subclass_of($this->backend, 'SihnonFramework_Auth_IUpdateable')) {
|
||||
throw new SihnonFramework_Exception_NotImplemented();
|
||||
}
|
||||
|
||||
$this->backend->removeUser($this->user);
|
||||
$this->user = null;
|
||||
$this->authenticated = false;
|
||||
}
|
||||
|
||||
public function changePassword($new_password) {
|
||||
if ( ! is_subclass_of($this->backend, 'SihnonFramework_Auth_IUpdateable')) {
|
||||
throw new SihnonFramework_Exception_NotImplemented();
|
||||
}
|
||||
|
||||
$this->backend->changePassword($this->user, $new_password);
|
||||
}
|
||||
|
||||
@@ -102,6 +114,10 @@ class SihnonFramework_Auth {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! is_subclass_of($this->backend, 'SihnonFramework_Auth_IPermissionable')) {
|
||||
throw new SihnonFramework_Exception_NotImplemented();
|
||||
}
|
||||
|
||||
return $this->backend->isAdministrator($this->user);
|
||||
}
|
||||
|
||||
@@ -114,6 +130,10 @@ class SihnonFramework_Auth {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! is_subclass_of($this->backend, 'SihnonFramework_Auth_IFinelyPermissionable')) {
|
||||
throw new SihnonFramework_Exception_NotImplemented();
|
||||
}
|
||||
|
||||
return $this->backend->hasPermission($this->user, $permission);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user