Custom Authentication

edited April 2012 in Modules
Hi,

I would like to customize the authentication system to use a third party application where I store user info now. Any suggestions on how to approach this? I was thinking I would modify the users_model.php file in modules/fuel/models, but I'm afraid this might be the wrong direction to take since future versions of fuel cms might break my changes. Any feedback you have is greatly appreciated.

Thanks!
Ryan

Comments

  • edited 10:05PM
    You could use the $module_overwrites configuration parameter in the fuel/application/config/MY_fuel_modules.php to point the users module to use your own custom users_model like so:
    $module_overwrites['users'] = array('model_name' => 'my_user_model');
  • edited 10:05PM
    Thanks for the advice. I have done that, but the module_overwrites does not seem to be referenced anywhere in the chain of events that calls up the user model.

    My call stack is:
    fuel/application/third_party/MX/Modules.php.Modules::load_file:137
    fuel/application/third_party/fuel/Loader.php.Fuel_Loader->model:237
    fuel/application/third_party/fuel/Loader.php.Fuel_Loader->module_model:107
    fuel/modules/fuel/controllers/login.php.Login->__construct:28
    fuel/codeigniter/core/CodeIgniter.php.require_once:267
    index.php.{main}:236

    I would've expected something in fuel/application/third_party/fuel/Loader.php to check the module_overwrites config option before loading the model, but it doesn't appear to do that.

    Here is the line I added to MY_fuel_modules.php:
    $config['module_overwrites']['users'] = array('model_name' => 'my_users_model');

    And here is my implementation (just a test version for now--saved in fuel/modules/fuel/models/my_users_model.php):

    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');

    require_once('users_model.php');

    class My_users_model {

    var $proxy_model;

    function __construct() {
    $proxy_model = new Users_model();
    }
    function valid_user($user, $pwd) {
    return $proxy_model->valid_user($user, $pwd);
    }
    function list_items($limit = NULL, $offset = NULL, $col = 'email', $order = 'desc') {
    return $proxy_model->list_items($limit, $offset , $col , $order );
    }
    function user_info($user_id) {
    return $proxy_model->user_info($user_id);
    }
    function reset_password($email) {
    return $proxy_model->reset_password($email);
    }
    function user_exists($email) {
    return $proxy_model->user_exists($email);
    }
    function options_list($key = 'id', $val = 'name', $where = array(), $order = 'name') {
    return $proxy_model->options_list($key , $val , $where , $order );
    }
    function form_fields($values = null) {
    return $proxy_model->form_fields($values );
    }
    function on_before_validate($values) {
    return $proxy_model->on_before_validate($values);
    }
    function on_before_clean($values) {
    return $proxy_model->on_before_clean($values);
    }
    function on_after_save($values) {
    return $proxy_model->on_after_save($values);
    }
    function delete($where) {
    return $proxy_model->delete($where);
    }
    function is_new_email($email) {
    return $proxy_model->is_new_email($email);
    }
    function is_editable_email($email, $id) {
    return $proxy_model->is_editable_email($email, $id);
    }

    }


    Thanks again!
    Ryan
  • edited 10:05PM
    Pretty sure your 'my_users_model' should be up in application/models
Sign In or Register to comment.