Welcome Guest, Not a member yet? Register   Sign In
Ion Auth - Lightweight Auth System based on Redux Auth 2

[eluser]techgnome[/eluser]
Yes... you should... otherwise how will it know what to fill it in with? I see that you have username in both tables... that's duplication of data and isn't necessary. It should just be in the users table...

For the fkey to work, you need to first insert into the user table, get the resulting ID, then insert into your meta table, passing the new user ID as the user_id field value.

-tg

[eluser]Ben Edmunds[/eluser]
Todlerone,

To expand on/clarify what techgnome said.

You should remove the username column from the meta table as it already exists in the users table, then when creating the user with ion_auth->register() you will pass in the username and meta data and it will propagate the correct tables. Also make sure you update your ion_auth config file with your meta columns.

[eluser]Todlerone[/eluser]
[quote author="Ben Edmunds" date="1291282543"]Todlerone,

To expand on/clarify what techgnome said.

You should remove the username column from the meta table as it already exists in the users table, then when creating the user with ion_auth->register() you will pass in the username and meta data and it will propagate the correct tables. Also make sure you update your ion_auth config file with your meta columns.[/quote]

TY very much Ben. Your an asset to codeigniter and open source. I have taken the username out of the meta table. I'm slowly understanding the inner workings of Ion Auth and it is doing exactly what I want. Can I ask you two more questions?

1) For my purposes I'm not allowing people to register themselfs, I'm doing it as admin only. This is for a very select group of people. I do want to be able to set there group names in the create form. What all do I need to do to make this happen? I suspect I can load the groups into an array and pass this to a select form input easily enough. Just not completely sure what else is needed other then following errors until I get it. I tried this and have come up against something I did that I can't fix...which leads me to question 2.
2) I'm now getting this error when I try to create a user.
Code:
Column 'group_id' cannot be null

INSERT INTO `users` (`username`, `password`, `email`, `group_id`, `ip_address`, `created_on`, `last_login`, `active`, `salt`) VALUES ('ticles', 'c7c5ddd126837ab3e71672a28603703f13fa34c8', '[email protected]', NULL, '142.21.240.74', 1291302985, 1291302985, 1, '2d16847247')

Not sure where I screwed up.

TY for your time.
CHEERS

[eluser]2think[/eluser]
Todlerone, totally agree with you on Ben being one of the immense assets to the Codeigniter community. There are quite a few people - for example, Phil Sturgeon, Jamie Rumbelow, Elliot Haughin, Collin Williams, and more - who make (made? LOL!) Codeigniter a much more pleasurable experience than it already is.

I'll try to offer my two cents worth and see if that helps any.

Have you checked if you set the group_id to NOT NULL in your DB schema? You're also passing in the group_id as NULL so why do that in the first place?

[eluser]Timothy_[/eluser]
Hello,

Has anyone else managed to connect ion_auth to a different database? As far as I can see there is no config option for it. The reason for this slightly unusual request is that I want to register a user in one application, but from then on the user will be logging in on another application.

Thanks,

Tim

[eluser]Ben Edmunds[/eluser]
Todlerone,

Are you passing a proper group name in your register method call? Is your default group setup properly in the config file?

[eluser]Ben Edmunds[/eluser]
Timothy_,

I've used it with MySQL and Postgres. Never both at the same time though... you would have to replicate your data to both databases... maybe you can expand on your use case a bit?

[eluser]Timothy_[/eluser]
[quote author="Ben Edmunds" date="1291363908"]Timothy_,

I've used it with MySQL and Postgres. Never both at the same time though... you would have to replicate your data to both databases... maybe you can expand on your use case a bit?[/quote]

Sorry, Reading back on my original question I wasn't being clear.

I have a main CI website that accesses a 'default' database set in the CI config/database file. It pulls things like menus, pages, posts etc from the default db.

I also have a completely separate database that just deals with user data. Its for a 'user account' CI app that I am about to start developing. This separation of databases is primarily done for security. If my main website gets hacked that's not good. If my users confidential details get exposed because of it that's a nightmare.

As you probably already know it is possible to connect to multiple DB's in CI.

What i was trying to do was have my main front end website basically setup a user in another CI installs DB. However reading back over this I think it would be easier just to pass the paramaters from my main website to the user account website and let the user account website do the registering, rather than have two instances of ION auth running in tandem on the same 'user accounts' DB.

Sorry for confusing everyone, including myself.

Thanks,

Tim

[eluser]Timothy_[/eluser]
Just continuing from above. I am curious to see if I can get ION_AUTH to connect to another database that is not the default in CI.

I tried changing line 66 in ion_auth_model.php

Code:
$this->load->database('myaccount', TRUE);

No luck.

The user was still registered to the SITE database not the MYACCOUNT database

Any suggestions??

Thanks,

Tim

[eluser]2think[/eluser]
Timothy_,

Have you tried switching to the other DB before calling any Ion_Auth functions? I can't see why that wouldn't work since Ion_Auth will use that particular DB.




Theme © iAndrew 2016 - Forum software by © MyBB