-
Notifications
You must be signed in to change notification settings - Fork 0
[UNMAINTAINED] Weblife1Auth provides an adapter for Zend_Auth for log on to the Weblife1 API
License
CHH/weblife1auth
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
==================== Weblife1Auth ================ What's this? This is an Adapter for the Zend_Auth Component which provides you with a way to let people log in with their Weblife1 User credentials in your Zend Framework Application. What is "Weblife1"? Weblife1 is the API powered by on of the biggest Austrian communities, Szene1. You can find out more on http://www.szene1.at [German] The legal Part This project is licensed under the BSD License and thus Open Source. For the details of the license please refer to the LICENSE file distributed with the project or under http://opensource.org/licenses/bsd-license.php Dependencies - PHP5 Client Library for the Weblife1 API, available through "http://www.szene1.at/community/appzone" - Zend Framework (tested on version 1.8) - at least PHP 5.2 Install Copy the contents of the downloaded archive or cloned git repository and the Weblife1 PHP Client Library in your library folder next to "Zend", so it looks like this: /library: |- Zend/ |- Weblife1Auth/ |- Weblife1Api/ If you are using Zend_Loader and set_include_path() in your Zend Framework Project, both Libraries should work out of the box. Otherwise you have to include the Library Files by yourself. Example: Usage is like every other Zend_Auth_Adapter. The constructor for the adapter expects an instance of Weblife1Api_Api, which you have to prepare for yourself (see the method _getWeblife1() in the example), as parameter. The Object returned by getResultSetObject() has the following properties: - id: The ID of the Weblife1 User - username - token: The Authtoken for user-based request to the Weblife1 API Here an example User Controller, based on Zend_Controller_Action class UserController extends Zend_Controller_Action { public function loginAction() { $auth = Zend_Auth::getInstance(); /** * Check if a user is already logged in, in this Browsing Session */ if( !$auth->hasIdentity() ) { $adapter = new Weblife1Auth_Auth_Adapter_Weblife1($this->_getWeblife1()); /** * These values will probably provided by some login form */ $adapter->setIdentity("myUsername")->setCredential("mySecretPassword"); $result = $auth->authenticate($adapter); /** * Check if Authentication has succeeded */ if( $result->isValid() ) { $data = $adapter->getResultSetObject(); $auth->getStorage()->write($data); $this->_helper->redirector("foo"); } else { /** * Print out some error message about the failed authentication attempt */ } } else { $this->_helper->redirector("foo"); } } public function logoutAction() { $auth = Zend_Auth::getInstance(); if( !$auth->hasIdentity() ) { $userSection = new Weblife1Api_Section_User($this->_getWeblife1()); $response = $userSection->logout(Zend_Auth::getInstance()->getIdentity()->token); if( !$response->error() ) { $auth->clearIdentity(); } $this->_helper->redirector("foo"); } } protected function _getWeblife1() { if($this->_weblife1 === null) { $this->_weblife1 = new Weblife1Api_Api( "myWeblife1ApiKey", "myWeblife1ApiSecret", null, Weblife1Api_Api::REQUEST_TYPE_GET ); } return $this->_weblife1; } }
About
[UNMAINTAINED] Weblife1Auth provides an adapter for Zend_Auth for log on to the Weblife1 API
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published