Skip to content

Commit

Permalink
Merge pull request #42 from nestauk/authenticate-admins-for-admin-age
Browse files Browse the repository at this point in the history
Authenticate admins
  • Loading branch information
cdccollins authored Oct 15, 2024
2 parents 92d47de + 3890318 commit ca351df
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions app/controllers/admins_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def create
# PATCH/PUT /admins/1
def update
if @admin.update(admin_params)
bypass_sign_in(@admin) if @admin == current_admin

redirect_to admins_path, notice: "Admin was successfully updated."
else
render :edit, status: :unprocessable_entity
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class ApplicationController < ActionController::Base
before_action :authenticate_admin!

def after_sign_up_path_for(user)
dashboard_users_path
end
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/contents_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class ContentsController < ApplicationController
before_action :authenticate_admin!

def new
@group = Group.find_by(id: params[:group_id])
@content = @group.contents.new
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/groups_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class GroupsController < ApplicationController
before_action :authenticate_admin!

def index
@groups = Group.order(:age_in_months)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class MessagesController < ApplicationController
before_action :authenticate_admin!, except: [:status, :incoming, :next]
skip_before_action :authenticate_admin!, only: [:status, :incoming, :next]
skip_before_action :verify_authenticity_token, only: [:status, :incoming]

def index
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class PagesController < ApplicationController
skip_before_action :authenticate_admin!

def privacy_policy
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class UsersController < ApplicationController
before_action :authenticate_admin!, only: [:index, :show, :dashboard]
skip_before_action :authenticate_admin!, except: [:index, :show, :dashboard]

def index
@users = User.all
Expand Down

0 comments on commit ca351df

Please sign in to comment.