GRN2-xx: Email and admin fix (#515)

* Email and admin fix

* Redirected super_admins to the admins page

* Small fix

* Update rooms_controller.rb
This commit is contained in:
farhatahmad
2019-05-09 18:07:18 -04:00
committed by Jesus Federico
parent 63ada8b3db
commit 75bde6a42d
10 changed files with 58 additions and 27 deletions

View File

@ -26,6 +26,7 @@ class RoomsController < ApplicationController
before_action :verify_room_ownership, except: [:create, :show, :join, :logout]
before_action :verify_room_owner_verified, only: [:show, :join],
unless: -> { !Rails.configuration.enable_email_verification }
before_action :verify_user_not_admin, only: [:show]
# POST /
def create
@ -244,11 +245,15 @@ class RoomsController < ApplicationController
unless @room.owner.activated?
flash[:alert] = t("room.unavailable")
if current_user
if current_user && !@room.owned_by?(current_user)
redirect_to current_user.main_room
else
redirect_to root_path
end
end
end
def verify_user_not_admin
redirect_to admins_path if current_user && current_user&.has_role?(:super_admin)
end
end