Cyclone
Cyclone

Reputation: 15269

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:

echo $user->description;

Everywhere, the error appear I'm trying to get the info from the $user variable. I guess its related to the tank_auth: I'm passing $user data trough the controller:

$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?

Upvotes: 1

Views: 659

Answers (1)

NDBoost
NDBoost

Reputation: 10634

this is probably because you have the server hash set to non portable..

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

/*
|--------------------------------------------------------------------------
| 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

just in case you were curious where this config comes into play, its in the blowfish hash creation:

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); what comes back?

Upvotes: 4

Related Questions