Search code examples
phpcodeignitercodeigniter-3ion-auth

Codeigniter + Ion Auth - Are "groups" relevant in my case?


I am currently using CodeIgniter with a homemade authentification system but I would like to switch to Ion Auth.

Every user's account is attached to a company's account. A company's account can have > 1 user's account attached.

Example:

- Company 1 => User id 1, user id 2, user id 3
- Company 2 => User id 4

etc

Is the "groups" function in Ion Auth relevant for storing this company data? I can, therefore, use the "users" table in order to save my users and the "groups" table in order to save companies. Is this choice relevant?


Solution

  • You can use groups to define the company and create additional fields in the users table (or separate) for the company data;

    Then you can use the below to check if the user is in a particular company/group

    if ($this->ion_auth->in_group("company1")){
        //your company stuff here
    }