Skip to content

Commit

Permalink
Fixes #1397
Browse files Browse the repository at this point in the history
* after_sign_in|up : Check for paths not urls (so that it works on localhost/http)
* remove duplicate IDs from sign_up page by not including it in modal too (related to #1064)
  • Loading branch information
Jimmy Angelakos committed Apr 20, 2018
1 parent 421fad0 commit 72d74e9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
19 changes: 10 additions & 9 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,17 @@ def store_location
end

def after_sign_in_path_for(resource)
if from_external_domain? || request.referer.eql?(new_user_session_url(:protocol => 'https')) || request.referer.eql?(new_user_registration_url(:protocol => 'https'))
referer_path = URI(request.referer).path unless request.referer.nil? or nil
if from_external_domain? || referer_path.eql?(new_user_session_path) || referer_path.eql?(new_user_registration_path) || referer_path.nil?
root_path
else
return request.referer unless request.referer.nil?
root_path
request.referer
end
end

def after_sign_up_path_for(resource)
if from_external_domain? or request.referer.eql?(new_user_session_url(:protocol => 'https'))
referer_path = URI(request.referer).path unless request.referer.nil? or nil
if from_external_domain? || referer_path.eql?(new_user_session_path) || referer_path.nil?
root_path
else
request.referer
Expand All @@ -85,11 +86,11 @@ def failed_create_error(obj, obj_name)
def failed_update_error(obj, obj_name)
"#{_('Could not update your %{o}.') % {o: obj_name}} #{errors_to_s(obj)}"
end

def failed_destroy_error(obj, obj_name)
"#{_('Could not delete the %{o}.') % {o: obj_name}} #{errors_to_s(obj)}"
end

def success_message(obj_name, action)
"#{_('Successfully %{action} your %{object}.') % {object: obj_name, action: action}}"
end
Expand All @@ -108,7 +109,7 @@ def is_json_array_of_objects?(string)

private
# Override rails default render action to look for a branded version of a
# template instead of using the default one. If no override exists, the
# template instead of using the default one. If no override exists, the
# default version in ./app/views/[:controller]/[:action] will be used
#
# The path in the app/views/branded/ directory must match the the file it is
Expand All @@ -117,7 +118,7 @@ def is_json_array_of_objects?(string)
def prepend_view_paths
prepend_view_path "app/views/branded"
end

def errors_to_s(obj)
if obj.errors.count > 0
msg = "<br />"
Expand All @@ -126,7 +127,7 @@ def errors_to_s(obj)
msg += "#{_(e)} - #{_(m)}<br />"
else
msg += "'#{obj[e]}' - #{_(m)}<br />"
end
end
end
msg
end
Expand Down
28 changes: 16 additions & 12 deletions app/views/shared/_access_controls.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
<%= _('Sign in') %>
</a>
</li>
<li role="presentation">
<a href="#create-account-form" role="tab" aria-controls="create-account-form" data-toggle="tab">
<%= _('Create account') %>
</a>
</li>
<% unless isActivePage(new_user_registration_path, true) %>
<li role="presentation">
<a href="#create-account-form" role="tab" aria-controls="create-account-form" data-toggle="tab">
<%= _('Create account') %>
</a>
</li>
<% end %>
</ul>

<div class="tab-content">
Expand All @@ -18,14 +20,16 @@
<div class="panel-body">
<%= render :partial => 'shared/sign_in_form' %>
</div>
</div>
</div>
</div>
<div id="create-account-form" role="tabpanel" class="tab-pane">
<div class="panel panel-default">
<div class="panel-body">
<%= render :partial => 'shared/create_account_form', locals: {extended: false} %>
<% unless isActivePage(new_user_registration_path, true) %>
<div id="create-account-form" role="tabpanel" class="tab-pane">
<div class="panel panel-default">
<div class="panel-body">
<%= render :partial => 'shared/create_account_form', locals: {extended: false} %>
</div>
</div>
</div>
</div>
<% end %>
</div>
</div>
</div>

0 comments on commit 72d74e9

Please sign in to comment.