for normal requests to /login, save the referrer and redir back there
properly closes #164
This commit is contained in:
parent
243b29240a
commit
bdbfedfb23
|
@ -11,6 +11,7 @@ class LoginController < ApplicationController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@title = "Login"
|
@title = "Login"
|
||||||
|
@referer ||= request.referer
|
||||||
render :action => "index"
|
render :action => "index"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -28,12 +29,22 @@ class LoginController < ApplicationController
|
||||||
if (rd = session[:redirect_to]).present?
|
if (rd = session[:redirect_to]).present?
|
||||||
session.delete(:redirect_to)
|
session.delete(:redirect_to)
|
||||||
return redirect_to rd
|
return redirect_to rd
|
||||||
else
|
elsif params[:referer].present?
|
||||||
return redirect_to "/"
|
begin
|
||||||
|
ru = URI.parse(params[:referer])
|
||||||
|
if ru.host == Rails.application.domain
|
||||||
|
return redirect_to ru.to_s
|
||||||
|
end
|
||||||
|
rescue => e
|
||||||
|
Rails.logger.error "error parsing referer: #{e}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return redirect_to "/"
|
||||||
end
|
end
|
||||||
|
|
||||||
flash.now[:error] = "Invalid e-mail address and/or password."
|
flash.now[:error] = "Invalid e-mail address and/or password."
|
||||||
|
@referer = params[:referer]
|
||||||
index
|
index
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -29,5 +29,9 @@
|
||||||
ask them for an invitation or <a href="/invitations/request">request one
|
ask them for an invitation or <a href="/invitations/request">request one
|
||||||
publicly</a>.
|
publicly</a>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<% if @referer.present? %>
|
||||||
|
<%= hidden_field_tag :referer, @referer %>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue