From 5c9842e1589ec8da95fd4cb614542fc0082c103e Mon Sep 17 00:00:00 2001 From: Lionel Tan MBP13 Date: Mon, 16 Jun 2014 23:48:15 +0800 Subject: [PATCH] Preserve the attempted path upon failed authentication Modify app.rb route '/auth/unauthenticated' do ensure that the return to path of session[:return_to] will remain even after a failed authentication attempt. --- app.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app.rb b/app.rb index b5f194a..10a665d 100644 --- a/app.rb +++ b/app.rb @@ -80,7 +80,7 @@ def authenticate! end post '/auth/unauthenticated' do - session[:return_to] = env['warden.options'][:attempted_path] + session[:return_to] = env['warden.options'][:attempted_path] if session[:return_to].nil? puts env['warden.options'][:attempted_path] puts env['warden'] flash[:error] = env['warden'].message || "You must log in" @@ -92,4 +92,4 @@ def authenticate! erb :protected end -end \ No newline at end of file +end