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

[eluser]JoeDRL[/eluser]
Is it me or I can't find a way to retrieve a user by it's username...?
I tried to use extra_where(array('username'=>$username)) followed by a get_user()but it sent me an error.

Am I doing things right?

Thanks a lot and very very good Auth system Smile


EDIT: Sorry, it worked after putting get_users() instead of get_user().

[eluser]Todlerone[/eluser]
[quote author="techgnome" date="1290756490"]So then include the login form as part of your view. There's nothing that says the login form has to be it's own view. Just make sure the form posts to the right controller, and if it fails that it redirects to an appropriate page.

-tg[/quote]
TY techgnome for your reply. I tried this and I get Undefined variable: message, username and password.

I have placed the auth controller index code into my home index controller and I copied the login function also. I also loaded the library('ion_auth').

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

I ran into this problem the other day as well. I just pushed a change to the library so the register() method will return the newly created users id if the registration was successful, otherwise it will return false.

So an example of how you get the users id now is:

Code:
$user_id = $this->ion_auth->register(......
[/quote]

Hey Ben,

Sorry about not getting back to you sooner, busy week!

Thanks so much for doing this. This is perfect!!!

Tim

[eluser]Todlerone[/eluser]
I tried putting the form in my main page view but I still get Undefined variable: message, username and password.

I have placed the auth controller index code into my home index controller and I copied the login function also. I also loaded the library(‘ion_auth’).

Ayone have suggestions.TY TY

[eluser]techgnome[/eluser]
What does your controller and form code look like? I don't know about others here, but I'm not clairvoyant.

-tg

[eluser]33cent[/eluser]
Ben Edmunds,

did you think about adding triggers into Ion Auth, something similar to Events in dx_auth?

reference: http://dexcell.shinsengumiteam.com/dx_au...vents.html

[eluser]Ben Edmunds[/eluser]
33cent,

For the most part everything you do with Ion Auth is called by you in a controller so you should be able to add any hooks or triggers you want to in your controller code.

Is there anywhere in particular that you need a trigger?

[eluser]Todlerone[/eluser]
[quote author="techgnome" date="1291062089"]What does your controller and form code look like? I don't know about others here, but I'm not clairvoyant.

-tg[/quote]
TY for your responce. I eventually worked it out. What I'm having a problem with now is the meta and user MySql tables. I have created a username column in the meta table but phpmyadmin won't let me set a foreign key index to the users table so that the username is passed.

Code:
CREATE TABLE IF NOT EXISTS `meta` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` mediumint(8) unsigned DEFAULT NULL,
  `username` varchar(15) NOT NULL,
  `first_name` varchar(50) DEFAULT NULL,
  `last_name` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;


CREATE TABLE IF NOT EXISTS `users` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `group_id` mediumint(8) unsigned NOT NULL,
  `ip_address` char(16) NOT NULL,
  `username` varchar(15) NOT NULL,
  `password` varchar(40) NOT NULL,
  `salt` varchar(40) DEFAULT NULL,
  `email` varchar(100) NOT NULL,
  `activation_code` varchar(40) DEFAULT NULL,
  `forgotten_password_code` varchar(40) DEFAULT NULL,
  `remember_code` varchar(40) DEFAULT NULL,
  `created_on` int(11) unsigned NOT NULL,
  `last_login` int(11) unsigned DEFAULT NULL,
  `active` tinyint(1) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;


ALTER TABLE `meta`
  ADD CONSTRAINT `meta_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

[eluser]techgnome[/eluser]
Don't use the username as the fkey... use the ID... which is already being set in your script there.

-tg

[eluser]Todlerone[/eluser]
[quote author="techgnome" date="1291238848"]Don't use the username as the fkey... use the ID... which is already being set in your script there.

-tg[/quote]
Thanks again techgnome. I set the user_id to a foreign key. However when I create a new user the field still is left blank.

Could I just add it to the additional data array?
Code:
$username  = substr(strtolower($this->input->post('first_name')), 0, 1).strtolower($this->input->post('last_name'));

$additional_data = array('first_name' => $this->input->post('first_name'),
                                     'last_name'  => $this->input->post('last_name'),
                        'username'  => $username);




Theme © iAndrew 2016 - Forum software by © MyBB