Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

unknown error "store referer" rails, restful_authentication

Posted on 2010-08-13
1
Medium Priority
?
669 Views
Last Modified: 2013-11-13
i am often seeing this error in my exception notification inbox. What is happening andd why is the user not seeing a nice flash error notification?

A NameError occurred in users#new:

 undefined local variable or method `store_referer' for #<UsersController:0xb69d33f0>
 [RAILS_ROOT]/lib/authenticated_system.rb:101:in `permission_denied'


def permission_denied      
       respond_to do |format|
         format.html do
           #Put your domain name here ex. http://www.example.com
           domain_name = "http://www.ndthub.com"
           http_referer = session[:refer_to]
           if http_referer.nil?
             store_referer
             http_referer = ( session[:refer_to] || domain_name )
           end
           flash[:error] = "You don't have permission to complete that action."
           #The [0..20] represents the 21 characters in http://localhost:3000
           #You have to set that to the number of characters in your domain name
           if http_referer[0..20] != domain_name  
            session[:refer_to] = nil
           redirect_to root_path
           else
             redirect_to_referer_or_default(root_path)  
           end
         end
         format.xml do
           headers["Status"]           = "Unauthorized"
           headers["WWW-Authenticate"] = %(Basic realm="Web Password")
           render :text => "You don't have permission to complete this action.", :status => '401 Unauthorized'
         end
       end
     end

Open in new window

0
Comment
Question by:depassion
1 Comment
 
LVL 14

Accepted Solution

by:
wesgarrison earned 2000 total points
ID: 33437376
Looks like you need a method for store_referer() since it can't find it.

The point of that is that someone goes to /admin/dashboard and isn't logged in, you would store that and redirect them to the login page.  If they logged in successfully, they would be redirected to where they were trying to go.

If you don't need that functionality, just redirect them to the root_path and get rid of everything else in that action.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Ruby, Call or invoke a API DLL library is easily via Win32API class, win32-api gem or other gems. For general DLL API call, there are quite a few references, some good tips list below: http://www.rubytips.org/2008/05/13/accessing-windows-api-fro…
Recently I spent hours debugging an issue in a Rails project where ActiveRecord was causing MySQL errors trying to create a User object of a class at the top level of a Single Table Inheritance model structure.  It turns out `.create` behaves differ…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month11 days, 12 hours left to enroll

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question