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

时间:2012-03-25 23:17:52

标签: php codeigniter tankauth

搬到新服务器后,我收到了很多这样的通知:

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查看@line 28内容是:

echo $user->description;

到处都出现错误,我正试图从$user变量中获取信息。 我猜它与tank_auth有关:我通过控制器传递$user数据:

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

...我已登录。

我的目录路径与早期服务器上的路径完全相同

问题出在哪里?

1 个答案:

答案 0 :(得分:4)

这可能是因为您将服务器哈希设置为非可移植..

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;

application/libraries/phpass-0.1/PasswordHash.php

的第203-235行

万一你好奇这个配置发挥作用,它在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 '*';
}

如果这不能解决问题

尝试print_r($user);回来的内容?