No commit activity in last 3 years
No release in over 3 years
A thin wrapper around the Rails `flash' object to assist in redirecting the user `back' after authentication.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

AuthenticationNeededSan¶ ↑

A thin wrapper around the Rails ‘flash’ object, to assist in redirecting a user ‘back’ to the page she originally requested.

For more info see the AuthenticationNeededSan class documentation.

Example¶ ↑

Consider an application which uses the authorization-san plugin. The ApplicationController would look something like the following:

class ApplicationController < ActionController::Base
  # If nobody was logged in and this resource is not accessable by all,
  # request authentication. Otherwise reply that the resource is forbidden.
  def access_forbidden
    # If the user is logged in and still can't view the page, we have to tell
    # them access is forbidden.
    if !@authenticated.nil?
      send_response_document :forbidden
    else
      authentication_needed!
    end
  end

  def when_authentication_needed
    redirect_to new_session_url
  end
end

Then from your sessions controller redirect the user back to the page she requested or the default one:

class SessionsController < ApplicationController
  def create
    # login code...
    finish_authentication_needed! or redirect_to(root_url)
  end
end

The authorization-san plugin is available at: github.com/Fingertips/authorization-san