Sha256: c5492579a6ac4444db9e0c14b96437c40c103a9a1973a561226aa3ff355f0279
Contents?: true
Size: 1.27 KB
Versions: 3
Compression:
Stored size: 1.27 KB
Contents
== 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: http://github.com/Fingertips/authorization-san
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
Fingertips-authentication-needed-san-1.1.1 | README.rdoc |
authentication-needed-san-1.1.2 | README.rdoc |
authentication-needed-san-1.1.1 | README.rdoc |