diff --git a/app/controllers/admins_controller.rb b/app/controllers/admins_controller.rb index 5e653cc..f1b1a4c 100644 --- a/app/controllers/admins_controller.rb +++ b/app/controllers/admins_controller.rb @@ -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 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 68e4e07..cadb40f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,4 +1,6 @@ class ApplicationController < ActionController::Base + before_action :authenticate_admin! + def after_sign_up_path_for(user) dashboard_users_path end diff --git a/app/controllers/contents_controller.rb b/app/controllers/contents_controller.rb index 6371290..3e5fd67 100644 --- a/app/controllers/contents_controller.rb +++ b/app/controllers/contents_controller.rb @@ -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 diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index cb3dd2e..3575a07 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -1,6 +1,4 @@ class GroupsController < ApplicationController - before_action :authenticate_admin! - def index @groups = Group.order(:age_in_months) end diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index a424d4c..b4acd1c 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -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 diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index df76487..fc924c9 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,4 +1,6 @@ class PagesController < ApplicationController + skip_before_action :authenticate_admin! + def privacy_policy end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 69c1f07..349a044 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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