5

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!

Won Jun Bae
  • 5,140
  • 6
  • 43
  • 49
Gareehc
  • 61
  • 1
  • 3

2 Answers2

3
  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.

acupofjose
  • 2,159
  • 1
  • 22
  • 40
0

Adding/removing fields to the default users table in the database is okay as long as you remove the associated code in Ion Library that depends on it. I encourage you to fork the Ion Authentication library and modify it as it fits your requirements.

If you want to leave the Ion Library unmodified, creating another table to store additional information is the right approach.

For modifying database tables/fields, using CodeIgniter's migration is recommended so that you can keep track of database changes inside a source code repository such as Git.

Won Jun Bae
  • 5,140
  • 6
  • 43
  • 49