Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enchantments #367

Closed
avramcosmin opened this issue Dec 15, 2012 · 6 comments
Closed

enchantments #367

avramcosmin opened this issue Dec 15, 2012 · 6 comments

Comments

@avramcosmin
Copy link

In ion_auth_model line[1692], I found this situation


$existing_group = $this->db->get_where('groups', array('name' => $group_name))->row();

with


$existing_group = $this->db->get_where($this->tables['groups'], array('name' => $group_name))->row();

Also,


if(!is_null($existing_group->id))
        {
...

triggers error

a better approach can be:


// bail if the group name already exists
        $existing_group = $this->db->get_where($this->tables['groups'], array('name' => $group_name))->num_rows();
        if($existing_group !== 0)
....

the solution I choose to solve this problems is:


        // bail if the group name already exists
        $existing_group = $this->db->get_where($this->tables['groups'], array('name' => $group_name))->num_rows();
        if($existing_group !== 0)
        {
            $this->set_error('group_already_exists');
            return FALSE;
        }
benedmunds added a commit that referenced this issue Dec 16, 2012
@benedmunds
Copy link
Owner

Implemented. Thanks!

@avramcosmin
Copy link
Author

It's me who's mistaken or there it must be ...->num_rows() instead of ...->num_row()???

Of course, if I try to create a group CI triggers an error


Fatal error: Call to undefined method CI_DB_mysqli_result::num_row() in ...\ionauth\models\ion_auth_model.php on line 1692

@benedmunds
Copy link
Owner

Ah thanks, it's fixed now. @alexy sent in a PR.

@sparky672
Copy link
Contributor

Thank-you for fixing this. When creating a Group, it would dump onto blank page. However, by using my custom template, it would generate a bunch of errors.

Implemented the changes above and now it's behaving normally... redirects back to "auth" page after Group is created.

I also changed this line in the auth Controller to force new group names to all lower-case, following the established naming convention...

$new_group_id = $this->ion_auth->create_group(strtolower($this->input->post('group_name')), $this->input->post('description'));

One may or may not want to make a similar change to the "edit_group" function.

@benedmunds
Copy link
Owner

Thanks @sparky672! I'll leave it out of the official code but it will be archived here if someone needs something similar. Thanks.

@avramcosmin
Copy link
Author

@sparky672 good observation. I myself use the strtolower. But, in some situations, maybe someone wishes to use upper and lower cases, so, it's best if for now the group name will give freedom to the user in deciding the case of the letters.

But, it will be a food idea to force the user name in $this->ion_auth->register() to strtolower.
Off course, it must first be debated and only after decided if it is a requirement or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants