GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 2090b9...b590a5 )
by Jesus
04:32
created

ApplicationHelper.fallback_translations()   A

Complexity

Conditions 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
# frozen_string_literal: true
2
3
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
4
#
5
# Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below).
6
#
7
# This program is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU Lesser General Public License as published by the Free Software
9
# Foundation; either version 3.0 of the License, or (at your option) any later
10
# version.
11
#
12
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
15
#
16
# You should have received a copy of the GNU Lesser General Public License along
17
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
18
19
require 'bbb_api'
20
require 'uri'
21
require 'i18n/language/mapping'
22
23
module ApplicationHelper
24
  include MeetingsHelper
25
  include BbbApi
26
  include I18n::Language::Mapping
27
28
  # Gets all configured omniauth providers.
29
  def configured_providers
30
    Rails.configuration.providers.select do |provider|
31
      Rails.configuration.send("omniauth_#{provider}")
32
    end
33
  end
34
35
  # Determines which providers can show a login button in the login modal.
36
  def iconset_providers
37
    providers = configured_providers & [:google, :twitter, :office365, :ldap]
38
39
    providers.delete(:twitter) if session[:old_twitter_user_id]
40
41
    providers
42
  end
43
44
  # Generates the login URL for a specific provider.
45
  def omniauth_login_url(provider)
46
    if provider == :ldap
47
      ldap_signin_path
48
    else
49
      "#{Rails.configuration.relative_url_root}/auth/#{provider}"
50
    end
51
  end
52
53
  # Determine if Greenlight is configured to allow user signups.
54
  def allow_user_signup?
55
    Rails.configuration.allow_user_signup
56
  end
57
58
  # Determines if the BigBlueButton endpoint is the default.
59
  def bigbluebutton_endpoint_default?
60
    Rails.configuration.bigbluebutton_endpoint_default == Rails.configuration.bigbluebutton_endpoint
61
  end
62
63
  # Returns language selection options
64
  def language_options
65
    locales = I18n.available_locales
66
    language_opts = [['<<<< ' + t("language_default") + ' >>>>', "default"]]
67
    locales.each do |locale|
68
      language_mapping = I18n::Language::Mapping.language_mapping_list[locale.to_s.gsub("_", "-")]
69
      language_opts.push([language_mapping["nativeName"], locale.to_s])
70
    end
71
    language_opts.sort
72
  end
73
74
  # Parses markdown for rendering.
75
  def markdown(text)
76
    markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,
77
      no_intra_emphasis: true,
78
      fenced_code_blocks: true,
79
      disable_indented_code_blocks: true,
80
      autolink: true,
81
      tables: true,
82
      underline: true,
83
      highlight: true)
84
85
    markdown.render(text).html_safe
86
  end
87
88
  def allow_greenlight_accounts?
89
    return Rails.configuration.allow_user_signup unless Rails.configuration.loadbalanced_configuration
90
    return false unless @user_domain && !@user_domain.empty? && Rails.configuration.allow_user_signup
91
    return false if @user_domain == "greenlight"
92
    # Proceed with retrieving the provider info
93
    begin
94
      provider_info = retrieve_provider_info(@user_domain, 'api2', 'getUserGreenlightCredentials')
95
      provider_info['provider'] == 'greenlight'
96
    rescue => e
97
      logger.info e
98
      false
99
    end
100
  end
101
102
  # Return all the translations available in the client side through javascript
103
  def current_translations
104
    @translations ||= I18n.backend.send(:translations)
105
    @translations[I18n.locale]
106
  end
107
108
  # Return the fallback translations available in the client side through javascript
109
  def fallback_translations
110
    @fallback_translations ||= I18n.backend.send(:translations)
111
    @fallback_translations[I18n.default_locale]
112
  end
113
114
  # Returns the page that the logo redirects to when clicked on
115
  def home_page
116
    return root_path unless current_user
117
    return admins_path if current_user.has_role? :super_admin
118
    current_user.main_room
119
  end
120
121
  def role_colour(role)
122
    role.colour || Rails.configuration.primary_color_default
123
  end
124
125
  def translated_role_name(role)
126
    if role.name == "denied"
127
      I18n.t("roles.banned")
128
    elsif role.name == "pending"
129
      I18n.t("roles.pending")
130
    elsif role.name == "admin"
131
      I18n.t("roles.admin")
132
    elsif role.name == "user"
133
      I18n.t("roles.user")
134
    else
135
      role.name
136
    end
137
  end
138
139
  def can_reset_password
140
    # Check if admin is editting user and user is a greenlight account
141
    Rails.configuration.enable_email_verification &&
142
      Rails.application.routes.recognize_path(request.env['PATH_INFO'])[:action] == "edit_user" &&
143
      @user.greenlight_account?
144
  end
145
146
  def google_analytics_url
147
    "https://www.googletagmanager.com/gtag/js?id=#{ENV['GOOGLE_ANALYTICS_TRACKING_ID']}"
148
  end
149
150
  def valid_url?(input)
151
    uri = URI.parse(input)
152
    !uri.host.nil?
153
  rescue URI::InvalidURIError
154
    false
155
  end
156
end
157