Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter Ion Auth editing users table

I'm new to Codeigniter and am just learning about the ion auth authentication system. I just have a few questions about it:

1) Is it possible to modify the default users table? (and would you advise for or against it?) I understand that there may be functions in the model, view, library or controller that expect the tables to have their exact default structures but for example, i have no need for a company column, so how can i go about removing it?

2) How can i add additional user information to the default users table? (Will it affect any functions if i just execute some sql to add columns to the default users table?)

3) This is kind of a follow on from theast question, would anyone recommend just creating a separate table for my additional user information and using their user id as the primary key in this new table and then just accessing tjat information via my own models?

Thanks for all your help!

like image 375
Gareehc Avatar asked Oct 19 '22 23:10

Gareehc


1 Answers

  1. Yes, it's possible to edit the users table, you will, however, have to go through the ion_auth_model / library to check for calls/writes to the field you are deleting. Otherwise you'll experience 500 errors for trying to insert data to a non-existent field.

  2. Yes, you can add additional fields in phpmyadmin where you have access to the database itself. The additional fields will either need to be set to null (to prevent errors on writing if the data isn't present), OR you'll have to include those fields as required and add them to ion_auth's existing functions.

  3. Solid idea, usually the rule I go by is keeping as little null fields as possible in the database. So if every user will have additional information, and you aren't expanding your table to a ridiculous length, then I'd append it to the users table. Otherwise, if you are adding optional additional fields, it's probably better to do an associative table.


Don't forget that you're the developer, libraries are used for convienice and security, but don't feel like you can't tailor them to better suit your needs. That's how we get cookie cutter applications.

like image 165
acupofjose Avatar answered Oct 21 '22 17:10

acupofjose