当前位置: 首页>>代码示例>>PHP>>正文


PHP Application_Model_User::getUsername方法代码示例

本文整理汇总了PHP中Application_Model_User::getUsername方法的典型用法代码示例。如果您正苦于以下问题:PHP Application_Model_User::getUsername方法的具体用法?PHP Application_Model_User::getUsername怎么用?PHP Application_Model_User::getUsername使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Application_Model_User的用法示例。


在下文中一共展示了Application_Model_User::getUsername方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: recoverUsername

 public function recoverUsername(Application_Model_User $user)
 {
     $options['email'] = $user->getEmail();
     $options['username'] = $user->getUsername();
     $options['firstName'] = $user->getFirstName();
     $options['lastName'] = $user->getLastName();
     $Mail = new Base_Mail();
     $Mail->sendForgotUsernameMail($options);
 }
开发者ID:riteshsahu1981,项目名称:we,代码行数:9,代码来源:Auth.php

示例2: loginAction

 public function loginAction()
 {
     if (Zend_Auth::getInstance()->hasIdentity()) {
         return $this->_redirect('/');
     }
     // process the form
     $form = new Application_Form_Login();
     if ($this->getRequest()->isPost() && $form->isValid($_POST)) {
         // check if the user exists
         $user_mapper = new Application_Model_UserMapper();
         $qry = "\n                SElECT *\n                FROM   user\n                WHERE  username = :credential\n                OR     email    = :credential";
         $params = array('credential' => $form->getValue('credential'));
         $user = $user_mapper->query($qry, $params);
         if ($user) {
             $user = new Application_Model_User($user[0]);
             // if the account is not active, prompt the user to activate the account
             if (!$user->getActive()) {
                 $this->_helper->FlashMessenger('User Not Activated');
                 return $this->_redirect('/registration/confirm/id/' . $user->getId());
             }
             // authenticate the user
             $db = Zend_Registry::get('db_default');
             $credential_choice = $params['credential'] == $user->getUsername() ? 'username' : 'email';
             $adapter = new Zend_Auth_Adapter_DbTable($db, 'user', $credential_choice, 'password_hash');
             $adapter->setIdentity($form->getValue('credential'));
             $adapter->setCredential(hash('sha256', $user->getPassword_salt() . $form->getValue('password')));
             $zend_auth = Zend_Auth::getInstance();
             $result = $zend_auth->authenticate($adapter);
             if ($result->isValid()) {
                 // store session information in database
                 $session_mapper = new Application_Model_SessionMapper();
                 $session = new Application_Model_Session(array('user_id' => $user->getId(), 'ip_address' => $_SERVER['REMOTE_ADDR'], 'login_timestamp' => date('Y-m-d H:i:s')));
                 $session_mapper->save($session);
                 // store user information in session variable
                 $session = new Zend_Session_Namespace('user');
                 $session->user = $user->get_array();
                 $this->_helper->FlashMessenger('Successful Login');
                 return $this->_redirect('/');
             } else {
                 echo "Authentication failed.";
             }
         } else {
             echo "Invalid username/email";
         }
     }
     $this->view->form = $form;
 }
开发者ID:alclin,项目名称:zend_framework,代码行数:47,代码来源:AuthController.php

示例3: doFacebookLogin

 public function doFacebookLogin()
 {
     $view = new Zend_view();
     $view->addHelperPath('Base/View/Helper/', 'Base_View_Helper');
     $facebook = $view->facebook();
     $session = $facebook->getSession();
     if ($session) {
         try {
             $Auth = new Base_Auth_Auth();
             $uid = $facebook->getUser();
             $user = new Application_Model_User();
             $where = "facebook_id='{$uid}'";
             $user = $user->fetchRow($where);
             if (false === $user) {
                 //create new user
                 $me = $facebook->api('/me');
                 $password = md5($Auth->passwordGenerator());
                 $user = new Application_Model_User();
                 if ($me['email'] != "") {
                     $where = "email='{$me['email']}'";
                     $user = $user->fetchRow($where);
                     if (false === $user) {
                         //insertex
                         $user = new Application_Model_User();
                         $user->setEmail($me['email']);
                         $user->setUsername($me['id']);
                         $user->setPassword($password);
                         $user->setfirstName($me['first_name']);
                         $user->setLastName($me['last_name']);
                         $user->setSex($me['gender']);
                         $user->setGapperOrFriend('gapper');
                         $user->setFacebookId($me['id']);
                         $user->setStatus('active');
                         $user->setDob('0000-00-00');
                         $user->setUserLevelId(1);
                     } else {
                         //update
                         $user->setFacebookId($me['id']);
                     }
                 } else {
                     $user = new Application_Model_User();
                     $user->setEmail($me['email']);
                     $user->setUsername($me['id']);
                     $user->setPassword($password);
                     $user->setfirstName($me['first_name']);
                     $user->setLastName($me['last_name']);
                     $user->setSex($me['gender']);
                     $user->setGapperOrFriend('gapper');
                     $user->setFacebookId($me['id']);
                     $user->setStatus('active');
                     $user->setDob('0000-00-00');
                     $user->setUserLevelId(1);
                 }
                 $user_id = $user->save();
                 if ($user_id > 0) {
                     $user->setDefaultPermissions($user_id);
                     if ($params['email'] != "") {
                         //send registration mail
                     }
                 }
             }
             //--do login --
             $params['email'] = $user->getEmail();
             //$params['username']=$user->getUsername();
             $params['password'] = $user->getPassword();
             $params['md5'] = "false";
             $Auth->doLogout();
             $loginStatus = true;
             if ($params['email'] != "") {
                 $loginStatus = $Auth->doLogin($params, 'email');
             } else {
                 $params['email'] = $user->getUsername();
                 $loginStatus = $Auth->doLogin($params, 'username');
             }
             if ($user->getEmail() == "" || is_null($user->getEmail())) {
                 //echo "<a href='/gapper/update-your-email' >Click here</a>";
                 //$this->_helper->redirector('update-your-email','gapper');
                 $result['email'] = "no";
                 return $result;
             }
             if ($loginStatus) {
                 $result['email'] = "ok";
                 return $result;
                 //echo "<a href='/gapper/where-i-am' >Click here</a>";
                 //$this->_helper->redirector('where-i-am','gapper');
             } else {
                 if ($user->getStatus() == "inactive") {
                     exit("Please activate your account. <br><a href='#' onclick='window.close();'>Close</a>");
                 } else {
                     if ($user->getStatus() == "deleted") {
                         exit("Your account status is deleted. Please contact administrator.");
                     } else {
                         exit("error while login");
                     }
                 }
             }
         } catch (FacebookApiException $e) {
             error_log($e);
         }
     }
//.........这里部分代码省略.........
开发者ID:riteshsahu1981,项目名称:we,代码行数:101,代码来源:User.php


注:本文中的Application_Model_User::getUsername方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。