codeigniter 3 - Using CI Ion Auth for a frontend/backend application -
i'm developing e commerce site need handle frontend , backend parts of applications. therefore, 'm going handle customer logins , admin user logins. e commerce site, people recommend store users , customers separately considering security. if not e commerce type, go user groups method , store users in single user table , manage privileges accordingly.
my problem how should use same ion auth authentication library frontend , backend while keeping customer table , user table separately. can understand underneath problem customer , admin session handling same auth library.
i think hmvc can not solve problem. i'm thinking of duplicating application folder or developing 2 standalone ci applications frontend , backend.
i have little experience in type of applications. can guide me correct path? in advance.
changing table ion_auth uses authenticate 'users' can accomplished. , can done dynamically @ run-time.
the name of table used authentication defined in configuration file application\config\ion_auth.php line of code.
$config['tables']['users'] = 'users'; however, default table name can whatever like. if, in database, changed name of table 'users' 'customers' change config file this:
$config['tables']['users'] = 'customers'; now customers default table used authenticate login.
but want 2 authentication tables, table admin purposes created , named 'admin_users'.
all need change value of $config['tables']['users'] 'admin_users'. done after ion_auth library loaded before ion_auth methods used. thing complicates making change way ion_auth's config loaded memory.
to prevent name collisions index added ion_auth's set of configuration items. so, in memory, ion_auth config item $config['tables']['users'] $config['ion_auth']['tables']['users']. need address index when dynamically setting new table name.
here code handles index , dynamically changes authentication table 'admin_users'.
// array @ $config['ion_auth']['tables'] $ion_tables = $this->config->item('tables', 'ion_auth'); // dynamically change item 'users' in array $ion_tables['users'] = "admin_users"; this code needed in controllers perform administrative functions. nothing needs happen in controllers "customers" because default.
Comments
Post a Comment