rocketer
rocketer

Reputation: 1071

Rails - How to prevent direct URL access to a method

I have a controller method that redirects to a url.

def after_sign_up_path_for(resource)
    return '/appli/key_registrations'
end

However, I want that users cannot access this url on their own (for example, if they enter myapp.com/appli/key_registrations in the url bar, they are redirected to somewhere else). How can I do that ?

Upvotes: 0

Views: 888

Answers (1)

fylooi
fylooi

Reputation: 3870

I would suggest to set a cookie in your redirection method and check for/remove that cookie in the registrations page.

Another alternative is to check request.referer for the referring URL, but bear in mind that the referrer can be spoofed.

Upvotes: 2

Related Questions