Search code examples
phpkohanakohana-auth

Kohana-Change password for admin using file driver


How can I change the password for a user in kohana, using the file driver?


Solution

  • For the Auth file driver the passwords are stored in the Auth config file - modules/auth/config/auth.php, so if you want to change user password you have to edit that file. By default the content looks like this:

    return array(
    
        'driver'       => 'file',
        'hash_method'  => 'sha256',
        'hash_key'     => NULL,
        'lifetime'     => 1209600,
        'session_type' => Session::$default,
        'session_key'  => 'auth_user',
    
        // Username/password combinations for the Auth File driver
        'users' => array(
            // 'admin' => 'b3154acf3a344170077d11bdb5fff31532f679a1919e716a02',
        ),
    
    );
    

    Note that passwords are encrypted with Auth::hash method - you have to use it first to get the hash value for your new password.

    I you are thinking of letting your users change their password through the website - there is no good way to do it and I'd suggest to switch to ORM driver instead.