Welcome Guest, Not a member yet? Register   Sign In
[Community Auth] Autologin after registration
#1

[eluser]falkencreative[/eluser]
Hello all. I'm using Community Auth on a web app (http://community-auth.com/) and I was hoping to build in functionality that would allow users to automatically be logged in after they register for an account. So, for example, they fill out the form, click "register" and the system registers them and automatically redirects them to the logged in area.

(I realize that the system is susceptible to more spam without checking for a valid email, but the security needs for this particular app are pretty low.)

Has anyone already done this? Or could point me in the right direction of what I'd need to change? Thanks in advance! I'm trying to figure it out on my own, but figured I should check with the community.


EDIT: Figured it out, though my solution is messy and messes with the MVC structure. If anyone knows of a cleaner way to do this, let me know.

Edited "user_model.php" by adding

Code:
// log user in automatically
$this->auth_model->login_update( $user_data['user_id'], $user_data['user_date'] );  
$this->session->set_userdata(
   'auth_identifier',
   $this->authentication->create_auth_identifier(
      $user_data['user_id'],
      $user_data['user_modified'],
      $user_data['user_date']
   )
);
redirect(base_url());

to the end of create_user() (about line 134), just before the system returns TRUE, indicating a new user was successfully registered.




Theme © iAndrew 2016 - Forum software by © MyBB