Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
SimpleAuth and md5
  • hi,
    am a new fuelphp user, and am working on a project that have 3500+ user with thier passwords encrypted with md5, and  I want to rewrite this project with fuelphp.

    can you show me how to use md5 instead of the actual auth method to preserve passwords!!!.

    thanks.


  • jraedejraede
    Accepted Answer
    Just replace the hash_password method to use md5. From what I recall about the package it just validates passwords by running hash_password on the input and comparing it to what's in the database. Additionally, the passwords for new users are hashed with hash_password as well.
  • thank you.
  • To be more exact: extend the Auth class in your application, and overload the hash_password method. It's not advisable to change code in the package, that would hamper future upgrades.
  • please can you show me how can i do it!!
    and if it is possible to preserve the same name (Auth) when doing stuffs...
  • HarroHarro
    Accepted Answer
    Read the docs section on extending core classes. The classes in the Auth package are added to the core, so they can be extended in the same way.

    In short (assuming you want to extend the login driver):
    - make sure the Auth package is always_load'ed
    - create app/classes/auth/login/simpleauth.php
    - define it as class Auth_Login_Simpleauth extends \Auth\Auth_Login_Simpleauth
    - add to the app bootstrap:

    Autoloader::add_classes(array(
        'Auth_Login_Simpleauth'  => APPPATH.'classes/auth/login/simpleauth.php',
    ));


  • thank you for your great help.
    but i still have an issue with overriding the "hash_password" method , below the app/classes/auth/login/simpleauth.php file content :

    <?php

    class Auth_Login_Simpleauth extends \Auth\Auth_Login_Simpleauth
    {
    public function hash_password($password)
    {
    return md5($password);
    }
    }

    it doesn't overload the function, but whene i change it on the package driver classe it work!!
  • thank you very match.
    the issue is solved by renaming the class name  from Auth_Login_Simpleauth to Auth_Login_SimpleAuth.

    thank you again.
  • HarroHarro
    Accepted Answer
    The name of the class has been changed in 1.6, Auth_Login_SimpleAuth is invalid according to the coding standards (class name segments should be ucfirst()).

    Remember this when you upgrade to 1.6.
  • really thank you for all the help you gave me.
  • No problem, here to help... :-)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion