Skip to content

Commit

Permalink
Merge pull request #225 from debtcollective/od/fix
Browse files Browse the repository at this point in the history
fix: prevent Drawer from breaking when changing between admin and user backends
  • Loading branch information
orlando authored Apr 1, 2020
2 parents c39ed6e + c8d3dc3 commit 97ae326
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
9 changes: 7 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ def logged_in?
end

def authenticate_user!
# TODO: redirect to login instead
head :unauthorized unless logged_in?
unless logged_in?
if request.format.json?
head :unauthorized
else
redirect_to root_path
end
end
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

class UsersController < ApplicationController
layout 'backoffice'
before_action :authenticate_user!
before_action :set_user
before_action :verify_current_user

# GET /users/1
# GET /users/1.json
Expand Down
4 changes: 3 additions & 1 deletion app/views/static_pages/home.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
</ul>
<ul>
<% if @current_user %>
<li><a href="<%= user_path(@current_user) %>" class="button primary" rel="nofollow">My Profile</a></li>
<li>
<%= link_to "My Account", user_path(@current_user), class: "button primary", data: { turbolinks: false } %>
</li>
<% else %>
<li><a href="<%= login_path %>" class="button secondary" rel="nofollow">Log In</a></li>
<li><a href="<%= signup_path %>" class="button primary" rel="nofollow">Sign Up</a></li>
Expand Down

0 comments on commit 97ae326

Please sign in to comment.