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
|
|
|
module Registrar |
20
|
|
|
extend ActiveSupport::Concern |
21
|
|
|
|
22
|
|
|
def approval_registration |
23
|
|
|
@settings.get_value("Registration Method") == Rails.configuration.registration_methods[:approval] |
24
|
|
|
end |
25
|
|
|
|
26
|
|
|
def invite_registration |
27
|
|
|
@settings.get_value("Registration Method") == Rails.configuration.registration_methods[:invite] |
28
|
|
|
end |
29
|
|
|
|
30
|
|
|
# Returns a hash containing whether the user has been invited and if they |
31
|
|
|
# signed up with the same email that they were invited with |
32
|
|
|
def check_user_invited(email, token, domain) |
33
|
|
|
return { present: true, verified: false } unless invite_registration |
34
|
|
|
return { present: false, verified: false } if token.nil? |
35
|
|
|
|
36
|
|
|
invite = Invitation.valid.find_by(invite_token: token, provider: domain) |
37
|
|
|
if invite.present? |
38
|
|
|
# Check if they used the same email to sign up |
39
|
|
|
same_email = email.casecmp(invite.email).zero? |
40
|
|
|
invite.destroy |
41
|
|
|
{ present: true, verified: same_email } |
42
|
|
|
else |
43
|
|
|
{ present: false, verified: false } |
44
|
|
|
end |
45
|
|
|
end |
46
|
|
|
|
47
|
|
|
# Checks if the user passes the requirements to be invited |
48
|
|
|
def passes_invite_reqs |
49
|
|
|
# check if user needs to be invited and IS invited |
50
|
|
|
invitation = check_user_invited(@user.email, session[:invite_token], @user_domain) |
51
|
|
|
|
52
|
|
|
@user.email_verified = true if invitation[:verified] |
53
|
|
|
|
54
|
|
|
invitation[:present] |
55
|
|
|
end |
56
|
|
|
|
57
|
|
|
# Add validation errors to model if they exist |
58
|
|
|
def valid_user_or_captcha |
59
|
|
|
valid_user = @user.valid? |
60
|
|
|
valid_captcha = Rails.configuration.recaptcha_enabled ? verify_recaptcha(model: @user) : true |
61
|
|
|
|
62
|
|
|
logger.error("Support: #{@user.email} creation failed: User params are not valid.") unless valid_user |
63
|
|
|
|
64
|
|
|
valid_user && valid_captcha |
65
|
|
|
end |
66
|
|
|
|
67
|
|
|
# Checks if the user trying to sign in with twitter account |
68
|
|
|
def check_if_twitter_account(log_out = false) |
69
|
|
|
unless params[:old_twitter_user_id].nil? && session[:old_twitter_user_id].nil? |
70
|
|
|
logout if log_out |
71
|
|
|
flash.now[:alert] = I18n.t("registration.deprecated.new_signin") |
72
|
|
|
session[:old_twitter_user_id] = params[:old_twitter_user_id] unless params[:old_twitter_user_id].nil? |
73
|
|
|
end |
74
|
|
|
end |
75
|
|
|
end |
76
|
|
|
|