2019-08-18 14:51:37 +02:00
|
|
|
module ApplicationHelper
|
2022-06-24 14:39:35 +02:00
|
|
|
def check_user_signed_in
|
2022-05-01 18:00:38 +02:00
|
|
|
unless user_signed_in?
|
2022-06-05 11:40:43 +02:00
|
|
|
flash[:alert] = t('backend.errors.not_logged_in')
|
2022-05-01 18:00:38 +02:00
|
|
|
redirect_to new_user_session_path
|
2022-06-24 14:39:35 +02:00
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def authenticate_admin
|
|
|
|
|
return if check_user_signed_in == false
|
|
|
|
|
|
|
|
|
|
unless current_user.admin?
|
|
|
|
|
flash[:alert] = t('backend.errors.not_enough_privileges')
|
|
|
|
|
redirect_to root_path
|
2022-05-01 18:00:38 +02:00
|
|
|
return
|
|
|
|
|
end
|
2022-06-24 14:39:35 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def authenticate_power_user
|
|
|
|
|
return if check_user_signed_in == false
|
2022-05-01 18:00:38 +02:00
|
|
|
|
2022-06-24 14:39:35 +02:00
|
|
|
unless current_user.admin? or current_user.moderator?
|
2022-06-05 11:40:43 +02:00
|
|
|
flash[:alert] = t('backend.errors.not_enough_privileges')
|
2022-05-01 18:00:38 +02:00
|
|
|
redirect_to root_path
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
2019-08-18 14:51:37 +02:00
|
|
|
end
|