简体   繁体   English

Codeigniter,tank_auth代码在移动到新服务器后不起作用

[英]Codeigniter, tank_auth code doesnt work after moving to the new server

After moving to the new server, I'm getting plenty of such notifications: 搬到新服务器后,我收到了很多这样的通知:

A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: account/settings.php

Line Number: 28

account/settings.php view @line 28 content is: account/settings.php查看@line 28内容是:

echo $user->description;

Everywhere, the error appear I'm trying to get the info from the $user variable. 无处不在,出现错误我正试图从$user变量获取信息。 I guess its related to the tank_auth : I'm passing $user data trough the controller: 我想它与tank_auth :我通过控制器传递$user数据:

$data['user'] = $this->tank_auth->user();
[..]
$this->load->view('account/settings', $data);

... and I'm logged in. ......我已经登录了。

My directories path is exactly the same as on the earlier server . 我的目录路径与早期服务器上的路径完全相同

Where is the problem? 问题出在哪儿?

this is probably because you have the server hash set to non portable.. 这可能是因为您将服务器哈希设置为非可移植的..

Lines 13-23 in application/config/tank_auth.php application/config/tank_auth.php第13-23行

/*
|--------------------------------------------------------------------------
| Security settings
|
| The library uses PasswordHash library for operating with hashed passwords.
| 'phpass_hash_portable' = Can passwords be dumped and exported to another server. If set to FALSE then you won't be able to use this database on another server.
| 'phpass_hash_strength' = Password hash strength.
|--------------------------------------------------------------------------
*/
## Set this to TRUE
$config['phpass_hash_portable'] = FALSE;
$config['phpass_hash_strength'] = 8;

Lines 203-235 of application/libraries/phpass-0.1/PasswordHash.php application/libraries/phpass-0.1/PasswordHash.php第203-235行

just in case you were curious where this config comes into play, its in the blowfish hash creation: 万一你好奇这个配置发挥作用,它在blowfish哈希创建中:

function HashPassword($password)
{
    $random = '';

    if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) {
        $random = $this->get_random_bytes(16);
        $hash =
            crypt($password, $this->gensalt_blowfish($random));
        if (strlen($hash) == 60)
            return $hash;
    }

    if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) {
        if (strlen($random) < 3)
            $random = $this->get_random_bytes(3);
        $hash =
            crypt($password, $this->gensalt_extended($random));
        if (strlen($hash) == 20)
            return $hash;
    }

    if (strlen($random) < 6)
        $random = $this->get_random_bytes(6);
    $hash =
        $this->crypt_private($password,
        $this->gensalt_private($random));
    if (strlen($hash) == 34)
        return $hash;

    # Returning '*' on error is safe here, but would _not_ be safe
    # in a crypt(3)-like function used _both_ for generating new
    # hashes and for validating passwords against existing hashes.
    return '*';
}

If that doesn't fix the problem 如果这不能解决问题

try print_r($user); 试试print_r($user); what comes back? 什么回来了?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM