summaryrefslogtreecommitdiff
path: root/demos/address-book/protected/pages/AddressProvider.php
diff options
context:
space:
mode:
authorwei <>2007-01-18 11:12:51 +0000
committerwei <>2007-01-18 11:12:51 +0000
commit645c9ef3729a604df17ecdf74258f92ef73dd4f5 (patch)
tree60b975893347259308c13eb87ae67f0c4c137835 /demos/address-book/protected/pages/AddressProvider.php
parent53c401bf07d89fad12c69f482d48126661efab88 (diff)
update address-book demo
Diffstat (limited to 'demos/address-book/protected/pages/AddressProvider.php')
-rw-r--r--demos/address-book/protected/pages/AddressProvider.php25
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