diff options
Diffstat (limited to 'demos/address-book/protected/pages/AddressProvider.php')
-rw-r--r-- | demos/address-book/protected/pages/AddressProvider.php | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/demos/address-book/protected/pages/AddressProvider.php b/demos/address-book/protected/pages/AddressProvider.php index bbfedd1b..ae0b369f 100644 --- a/demos/address-book/protected/pages/AddressProvider.php +++ b/demos/address-book/protected/pages/AddressProvider.php @@ -6,9 +6,31 @@ Prado::using('Application.pages.AddressRecord'); * @version $Id$
* @since 3.1
*/
-class AddressProvider
+class AddressProvider extends TApplicationComponent
{
/**
+ * @throws exception if not logged in
+ */
+ public function __construct($server)
+ {
+ $authMethods = $server->getRequestedMethod()!=='login';
+ $guestUser = $this->User ? $this->User->IsGuest : true;
+ if($authMethods && $guestUser)
+ throw new TException('authentication required');
+ }
+
+ /**
+ * @param string $username
+ * @param string $password
+ * @return boolean
+ * @soapmethod
+ */
+ public function login($username, $password)
+ {
+ return $this->Application->Modules['auth']->login($username, $password);
+ }
+
+ /**
* @return AddressRecord[]
* @soapmethod
*/
@@ -17,7 +39,6 @@ class AddressProvider return AddressRecord::finder()->findAll();
}
-
/**
* Update address if $data->id > 0, otherwise add new address.
* @param AddressRecord $data
|