Sha256: 22935ecff20bfd9b4ca93eb6a2e42d77974ea581bdbb6cf41bc7ed5a122244bb

Contents?: true

Size: 1.39 KB

Versions: 61

Compression:

Stored size: 1.39 KB

Contents

# This controller handles the login/logout function of the site.  
class <%= controller_class_name %>Controller < ApplicationController
  # Be sure to include AuthenticationSystem in Application Controller instead
  include AuthenticatedSystem

  # render new.rhtml
  def new
  end

  def create
    logout_keeping_session!
    <%= file_name %> = <%= class_name %>.authenticate(params[:login], params[:password])
    if <%= file_name %>
      # Protects against session fixation attacks, causes request forgery
      # protection if user resubmits an earlier form using back
      # button. Uncomment if you understand the tradeoffs.
      # reset_session
      self.current_<%= file_name %> = <%= file_name %>
      new_cookie_flag = (params[:remember_me] == "1")
      handle_remember_cookie! new_cookie_flag
      redirect_back_or_default('/')
      flash[:notice] = "Logged in successfully"
    else
      note_failed_signin
      @login       = params[:login]
      @remember_me = params[:remember_me]
      render :action => 'new'
    end
  end

  def destroy
    logout_killing_session!
    flash[:notice] = "You have been logged out."
    redirect_back_or_default('/')
  end

protected
  # Track failed login attempts
  def note_failed_signin
    flash[:error] = "Couldn't log you in as '#{params[:login]}'"
    logger.warn "Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}"
  end
end

Version data entries

61 entries across 61 versions & 9 rubygems

Version Path
dwaite-restful-authentication-1.1.1 generators/authenticated/templates/controller.rb
genki-restful-authentication-1.1.1 generators/authenticated/templates/controller.rb
ggoodale-restful-authentication-1.1.1 generators/authenticated/templates/controller.rb
jcnetdev-restful-authentication-1.0.20080704 generators/authenticated/templates/controller.rb
simonmenke-mr_authentication-0.0.1 vendor/plugins/restful-authentication/generators/authenticated/templates/controller.rb
smukherjee-openbill-0.1.5 vendor/plugins/restful-authentication/generators/authenticated/templates/controller.rb
smukherjee-openbill-0.1.6 vendor/plugins/restful-authentication/generators/authenticated/templates/controller.rb
smukherjee-openbill-0.1.7 vendor/plugins/restful-authentication/generators/authenticated/templates/controller.rb
tournament-5.0.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/controller.rb
branston-0.6.6 lib/branston/vendor/plugins/restful_authentication/generators/authenticated/templates/controller.rb
branston-0.6.5 lib/branston/vendor/plugins/restful_authentication/generators/authenticated/templates/controller.rb
branston-0.6.4 lib/branston/vendor/plugins/restful_authentication/generators/authenticated/templates/controller.rb
branston-0.6.3 lib/branston/vendor/plugins/restful_authentication/generators/authenticated/templates/controller.rb
branston-0.6.2 lib/branston/vendor/plugins/restful_authentication/generators/authenticated/templates/controller.rb
tournament-4.2.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/controller.rb
tournament-4.0.2 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/controller.rb
tournament-4.0.0 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/controller.rb
branston-0.6.1 lib/branston/vendor/plugins/restful_authentication/generators/authenticated/templates/controller.rb
branston-0.6.0 lib/branston/vendor/plugins/restful_authentication/generators/authenticated/templates/controller.rb
tournament-3.3.3 webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/controller.rb