mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 03:07:52 +01:00
- Added Site settings > Authentication section - Create/edit/delete your custom oauth2 configurations - Login or signup with oauth2
38 lines
960 B
Ruby
38 lines
960 B
Ruby
module ApplicationHelper
|
|
def check_user_signed_in
|
|
unless user_signed_in?
|
|
flash[:alert] = t('errors.not_logged_in')
|
|
redirect_to new_user_session_path
|
|
|
|
return false
|
|
end
|
|
end
|
|
|
|
def authenticate_admin
|
|
return if check_user_signed_in == false
|
|
|
|
unless current_user.admin?
|
|
flash[:alert] = t('errors.not_enough_privileges')
|
|
redirect_to root_path
|
|
return
|
|
end
|
|
end
|
|
|
|
def authenticate_power_user
|
|
return if check_user_signed_in == false
|
|
|
|
unless current_user.admin? or current_user.moderator?
|
|
flash[:alert] = t('errors.not_enough_privileges')
|
|
redirect_to root_path
|
|
return
|
|
end
|
|
end
|
|
|
|
def add_subdomain_to(url_helper, resource=nil, options={})
|
|
options[:subdomain] = Current.tenant_or_raise!.subdomain if Rails.application.multi_tenancy?
|
|
options[:host] = Rails.application.base_url
|
|
|
|
resource ? url_helper.call(resource, options) : url_helper.call(options)
|
|
end
|
|
end
|