From 645c9ef3729a604df17ecdf74258f92ef73dd4f5 Mon Sep 17 00:00:00 2001 From: wei <> Date: Thu, 18 Jan 2007 11:12:51 +0000 Subject: update address-book demo --- .../protected/pages/AddressProvider.php | 25 ++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'demos/address-book/protected/pages/AddressProvider.php') 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,8 +6,30 @@ 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 -- cgit v1.2.3