Updating sessions controller to use resource oriented style. Changing authenticate method to accept a hash of attributes.

This commit is contained in:
Carlos A. da Silva
2009-10-10 16:20:23 -03:00
parent 15c5d9e049
commit 4e263b96c9
7 changed files with 26 additions and 24 deletions

View File

@@ -10,8 +10,9 @@ class SessionsController < ApplicationController
# POST /session
#
def create
if user = resource_class.authenticate(params[:session][:email], params[:session][:password]) #authenticate
self.current_user = user
self.resource = resource_class.authenticate(params[resource_name])
if resource #authenticate
self.current_user = resource
flash[:success] = I18n.t(:signed_in, :scope => [:devise, :sessions], :default => 'Signed in successfully.')
redirect_to root_path
else

View File

@@ -1,6 +1,6 @@
<h2><%= t '.title', :default => 'Sign in', :scope => :devise %></h2>
<% form_for :session, :url => session_path do |f| -%>
<% form_for resource_name, :url => session_path do |f| -%>
<p><%= f.label :email %></p>
<p><%= f.text_field :email %></p>
<p><%= f.label :password %></p>