/** * Glo_Application_Resource_Auth * * @return Glo_Application_Resource_Auth */ public function init() { $options = $this->getOptions(); $dbAdapter = Zend_Registry::get(Glo_Db::CONN_WRITE); $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter, $options['options']['authTable'], $options['options']['usernameColumn'], $options['options']['passwordColumn'], $options['options']['passwordTreatment']); $auth = Glo_Auth::getInstance(); $auth->setAdapter($authAdapter); }
/** * tokenLoginAction * * Request method: POST * * End Point: /auth/token-login * * Parameters: * - vanity_url * - security_code * * Sample Request: * <pre style="border: 1px solid #3D578C; background: #E2E8F2"> * /auth/token-login (data is in the POST) * </pre> * * Sample Response: * <pre style="border: 1px solid #3D578C; background: #E2E8F2"> { "user_uuid": "e77a48ed-ff5a-4c12-9a59-5c48379d3160", "session_uuid": "361092b7-d0b8-406c-8409-41db2853baf2" } * </pre> * * @return void */ public function tokenLoginAction() { $form = new App_Form_Auth_TokenLogin(); $jsonData = $this->getRequestJson(); if ($form->isValid($jsonData)) { $data = $form->getValues(); // get the user $map = new App_Model_Map_User(); $user = $map->fetchByVanityUrl($data['vanity_url']); // validate the security code if ($data['security_code'] == App_Model_DbTable_User::getSecurityToken($user->user_uuid)) { // authenticate $auth = Glo_Auth::getInstance(); $auth->forceAuthenticate($user->user_uuid); $this->view->user_uuid = $user->user_uuid; $this->view->session_uuid = Zend_Session::getId(); // $map = new App_Model_Map_UserAction(); $map->save(array('user_uuid' => $this->view->user_uuid, 'action' => 'token login')); $this->_helper->json($this->view); } else { throw new Glo_Auth_Exception_Failed('Incorrect security token provided.'); } } else { throw new Glo_Exception_BadData(array_shift(array_shift($form->getMessages()))); } }