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


PHP BackendAuthentication::getEncryptedPassword方法代码示例

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


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

示例1: loginUser

    /**
     * Login the user with the given credentials.
     * Will return a boolean that indicates if the user is logged in.
     *
     * @return	bool
     * @param	string $login		The users login.
     * @param	string $password	The password provided by the user.
     */
    public static function loginUser($login, $password)
    {
        // redefine
        $login = (string) $login;
        $password = (string) $password;
        // init vars
        $db = BackendModel::getDB(true);
        // fetch the encrypted password
        $passwordEncrypted = BackendAuthentication::getEncryptedPassword($login, $password);
        // check in database (is the user active and not deleted, are the email and password correct?)
        $userId = (int) $db->getVar('SELECT u.id
										FROM users AS u
										WHERE u.email = ? AND u.password = ? AND u.active = ? AND u.deleted = ?
										LIMIT 1', array($login, $passwordEncrypted, 'Y', 'N'));
        // not 0 = valid user!
        if ($userId !== 0) {
            // cleanup old sessions
            self::cleanupOldSessions();
            // build the session array (will be stored in the database)
            $session = array();
            $session['user_id'] = $userId;
            $session['secret_key'] = BackendAuthentication::getEncryptedString(SpoonSession::getSessionId(), $userId);
            $session['session_id'] = SpoonSession::getSessionId();
            $session['date'] = BackendModel::getUTCDate();
            // insert a new row in the session-table
            $db->insert('users_sessions', $session);
            // store some values in the session
            SpoonSession::set('backend_logged_in', true);
            SpoonSession::set('backend_secret_key', $session['secret_key']);
            // return result
            return true;
        } else {
            // reset values for invalid users. We can't destroy the session because session-data can be used on the site.
            SpoonSession::set('backend_logged_in', false);
            SpoonSession::set('backend_secret_key', '');
            // return result
            return false;
        }
    }
开发者ID:netconstructor,项目名称:forkcms,代码行数:47,代码来源:authentication.php


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