User Login (process_login)


#1

Hiya - before I start let me tell you i’m a Nuby on Rails.

I’ve created a user registration within my application that requires
email validation and that seems to be working fine.

I’m now creating the user login page and have the following code in my
UsersController:

def login
@user = User.new
@user.username = params[:username]
end

def process_login
if user = User.authenticate(params[:user])
session[:id] = user.id # Remember the user’s id during this
session
redirect_to session[:return_to] || ‘/’
else
flash[:error] = ‘Invalid login.’
redirect_to :action => ‘login’, :username =>
params[:user][:username]
end
end

def logout
reset_session
flash[:message] = ‘You are now logged out.’
redirect_to :action => ‘login’
end

I’ve attempted to login using a validated account that I set up but
can’t seem to get passed the process_login.

It doesn’t seem to attempt to ‘authenticate’. I’m just seeing
process_login.rhtml. Is there something missing in my code?

Cheers
Craig


#2

I would suggest taking a look at some authentication plugins, even if
you don’t actually end up using one of them.

I personally like the restful_authentication plugin:

http://agilewebdevelopment.com/plugins/restful_authentication

On May 23, 11:24 am, Craig R. removed_email_address@domain.invalid


#3

Robert W. wrote:

I would suggest taking a look at some authentication plugins, even if
you don’t actually end up using one of them.

I personally like the restful_authentication plugin:

http://agilewebdevelopment.com/plugins/restful_authentication

On May 23, 11:24 am, Craig R. removed_email_address@domain.invalid

I had a look at that but I get the error:

Couldn’t find ‘authenticated’ generator


#4

Did you first install the plugin into your rails application using:

./script/plugin install
http://svn.techno-weenie.net/projects/plugins/restful_authentication

On May 23, 11:45 am, Craig R. removed_email_address@domain.invalid