FEATURE: add email query param to login, signup, and password-reset URLs to prefill form

This commit is contained in:
Neil Lalonde
2016-01-19 16:53:46 -05:00
parent 11ea16a91a
commit 9ad226aaa8
6 changed files with 28 additions and 6 deletions

View File

@ -6,8 +6,10 @@ class StaticController < ApplicationController
skip_before_filter :check_xhr, :redirect_to_login_if_required
skip_before_filter :verify_authenticity_token, only: [:cdn_asset, :enter, :favicon]
PAGES_WITH_EMAIL_PARAM = ['login', 'password_reset', 'signup']
def show
return redirect_to(path '/') if current_user && params[:id] == 'login'
return redirect_to(path '/') if current_user && (params[:id] == 'login' || params[:id] == 'signup')
map = {
"faq" => {redirect: "faq_url", topic_id: "guidelines_topic_id"},
@ -44,6 +46,10 @@ class StaticController < ApplicationController
return
end
if PAGES_WITH_EMAIL_PARAM.include?(@page) && params[:email]
cookies[:email] = { value: params[:email], expires: 1.day.from_now }
end
file = "static/#{@page}.#{I18n.locale}"
file = "static/#{@page}.en" if lookup_context.find_all("#{file}.html").empty?
file = "static/#{@page}" if lookup_context.find_all("#{file}.html").empty?