2018-05-07 16:47:29 -07:00
# frozen_string_literal: true
2017-03-06 23:54:29 +05:30
module UsersHelper
##
# Includes functions related to users
##
# Set devise_mapping for devise so that we can call the devise help links (views/devise/shared/_links) from anywhere (eg sign_up form in proposals#new)
def devise_mapping
@devise_mapping || = Devise . mappings [ :user ]
end
def omniauth_configured
2022-02-17 16:39:45 +01:00
return Devise . omniauth_providers if OmniAuth . config . test_mode
2017-03-06 23:54:29 +05:30
providers = [ ]
Devise . omniauth_providers . each do | provider |
2022-05-06 14:27:15 +02:00
providers << provider if ENV . fetch ( " OSEM_ #{ provider . upcase } _KEY " , nil ) . present? && ENV . fetch ( " OSEM_ #{ provider . upcase } _SECRET " , nil ) . present?
2017-03-06 23:54:29 +05:30
end
2017-12-04 13:05:23 +05:30
providers . uniq
2017-03-06 23:54:29 +05:30
end
# Receives a hash, generated from User model, function get_roles
# Outputs the roles of a user, including the conferences for which the user has the roles
# Eg. organizer(oSC13, oSC14), cfp(oSC12, oSC13)
def show_roles ( roles )
roles . map { | x | x [ 0 ] . titleize + ' (' + x [ 1 ] . join ( ', ' ) + ')' } . join ', '
end
end