Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
app: always use _path methods instead of *_url
Browse files Browse the repository at this point in the history
The _url methods should only be used when the full path (+ hostname, etc.) is
needed. This is usually only the case for things like emails and views that are
to be accessed from outside the web app. This can usually be workarounded
through NGinx and similar tools, but it's better to have this behavior even
without such tools.

See #677

Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
  • Loading branch information
mssola committed Jan 26, 2016
1 parent 5626ad9 commit 93259fc
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class ApplicationController < ActionController::Base
# this case, the user will be asked to submit an email.
# 2. Everything is fine, go to the root url.
def after_sign_in_path_for(_resource)
current_user.email? ? root_url : edit_user_registration_url
current_user.email? ? root_path : edit_user_registration_path
end

def after_sign_out_path_for(_resource)
new_user_session_url
new_user_session_path
end

def fixes
Expand Down Expand Up @@ -55,7 +55,7 @@ def force_update_profile!
return unless current_user && !current_user.email?
return if protected_controllers?

redirect_to edit_user_registration_url
redirect_to edit_user_registration_path
end

# Redirect admin users to the registries#new page if no registry has been
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/auth/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def create
sign_up(resource_name, resource)
respond_with resource, location: after_sign_up_path_for(resource)
else
redirect_to new_user_registration_url,
redirect_to new_user_registration_path,
alert: resource.errors.full_messages
end
end
Expand All @@ -44,10 +44,10 @@ def update
end

if success
redirect_to edit_user_registration_url,
redirect_to edit_user_registration_path,
notice: "Profile updated successfully!"
else
redirect_to edit_user_registration_url,
redirect_to edit_user_registration_path,
alert: resource.errors.full_messages
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/auth/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def new
# For some reason if we get here from the root path, we'll get a flashy
# alert message.
flash[:alert] = nil
redirect_to new_user_registration_url
redirect_to new_user_registration_path
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/passwords/edit.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ section.row-0
= f.button class: 'classbutton btn btn-primary btn-block btn-lg' do
i.fa.fa-check Change my password

.text-center = link_to 'Go back to the login page', new_user_session_url
.text-center = link_to 'Go back to the login page', new_user_session_path
2 changes: 1 addition & 1 deletion app/views/devise/passwords/new.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ section.row-0
= f.button class: 'classbutton btn btn-primary btn-block btn-lg' do
i.fa.fa-check Reset password

.text-center = link_to 'Go back to the login page', new_user_session_url, class: 'btn btn-link'
.text-center = link_to 'Go back to the login page', new_user_session_path, class: 'btn btn-link'
2 changes: 1 addition & 1 deletion app/views/devise/registrations/new.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ section.sign-up class=(@have_users ? '' : 'first-user')
- else
| Create admin
- if @have_users
.text-center = link_to 'I already have an account. Login.', new_user_session_url, class: 'btn btn-link'
.text-center = link_to 'I already have an account. Login.', new_user_session_path, class: 'btn btn-link'
2 changes: 1 addition & 1 deletion app/views/devise/sessions/new.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ section.row-0
- else
.row
.col-sm-6.create-new-account
= link_to 'Create a new account', new_user_registration_url, class: 'btn btn-link'
= link_to 'Create a new account', new_user_registration_path, class: 'btn btn-link'
- if !Portus::LDAP.enabled?
.forgot-password
= link_to "I forgot my password", new_user_password_path, class: 'btn btn-link'
4 changes: 2 additions & 2 deletions app/views/shared/_header.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
.hidden-xs
= user_image_tag(current_user.email)

= link_to edit_user_registration_url, class: 'nav-a' do
= link_to edit_user_registration_path, class: 'nav-a' do
span.username = current_user.username
= link_to destroy_user_session_url, method: :delete, class: 'btn btn-default', id: 'logout' do
= link_to destroy_user_session_path, method: :delete, class: 'btn btn-default', id: 'logout' do
i.fa.fa-sign-out

0 comments on commit 93259fc

Please sign in to comment.