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
Pull Request — master (#579)
by Jesus
07:30
created

ApplicationHelper.parse_user_domain()   A

Complexity

Conditions 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
c 0
b 0
f 0
dl 0
loc 7
rs 10
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
21
module ApplicationHelper
22
  include MeetingsHelper
23
  include BbbApi
24
25
  # Gets all configured omniauth providers.
26
  def configured_providers
27
    Rails.configuration.providers.select do |provider|
28
      Rails.configuration.send("omniauth_#{provider}")
29
    end
30
  end
31
32
  # Determines which providers can show a login button in the login modal.
33
  def iconset_providers
34
    configured_providers & [:google, :twitter, :office365]
35
  end
36
37
  # Generates the login URL for a specific provider.
38
  def omniauth_login_url(provider)
39
    if provider == :bn_launcher
40
      customer = parse_user_domain(request.host)
41
      customer_info = retrieve_provider_info(customer, 'api2', 'getUserGreenlightCredentials')
42
43
      "#{Rails.configuration.relative_url_root}/auth/#{customer_info['provider']}"
44
    else
45
      "#{Rails.configuration.relative_url_root}/auth/#{provider}"
46
    end
47
  end
48
49
  def parse_user_domain(hostname)
50
    return hostname.split('.').first if Rails.configuration.url_host.empty?
51
    Rails.configuration.url_host.split(',').each do |url_host|
52
      return hostname.chomp(url_host).chomp('.') if hostname.include?(url_host)
53
    end
54
    ''
55
  end
56
57
  # Determine if Greenlight is configured to allow user signups.
58
  def allow_user_signup?
59
    Rails.configuration.allow_user_signup
60
  end
61
62
  # Determines if the BigBlueButton endpoint is the default.
63
  def bigbluebutton_endpoint_default?
64
    Rails.configuration.bigbluebutton_endpoint_default == Rails.configuration.bigbluebutton_endpoint
65
  end
66
67
  # Returns language selection options
68
  def language_options
69
    locales = I18n.available_locales
70
    language_opts = [['<<<< ' + t("language_default") + ' >>>>', "default"]]
71
    locales.each do |locale|
72
      language_name = t("language_name", locale: locale)
73
      language_name = locale.to_s if locale != :en && language_name == 'English'
74
      language_opts.push([language_name, locale.to_s])
75
    end
76
    language_opts.sort
77
  end
78
79
  # Parses markdown for rendering.
80
  def markdown(text)
81
    markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,
82
      no_intra_emphasis: true,
83
      fenced_code_blocks: true,
84
      disable_indented_code_blocks: true,
85
      autolink: true,
86
      tables: true,
87
      underline: true,
88
      highlight: true)
89
90
    markdown.render(text).html_safe
91
  end
92
93
  def allow_greenlight_accounts?
94
    return Rails.configuration.allow_user_signup unless Rails.configuration.loadbalanced_configuration
95
    return false unless @user_domain && !@user_domain.empty? && Rails.configuration.allow_user_signup
96
    # Proceed with retrieving the provider info
97
    begin
98
      provider_info = retrieve_provider_info(@user_domain, 'api2', 'getUserGreenlightCredentials')
99
      provider_info['provider'] == 'greenlight'
100
    rescue => e
101
      logger.info e
102
      false
103
    end
104
  end
105
106
  # Return all the translations available in the client side through javascript
107
  def current_translations
108
    @translations ||= I18n.backend.send(:translations)
109
    @translations[I18n.locale].with_indifferent_access[:javascript] || {}
110
  end
111
112
  # Returns the page that the logo redirects to when clicked on
113
  def home_page
114
    return root_path unless current_user
115
    return admins_path if current_user.has_role? :super_admin
116
    current_user.main_room
117
  end
118
end
119