GRN-80: Allow local accounts on multitenant (#428)

* Changed the way the omniauth providers are declared

* Allow local authentication for multitenant mode based on customer settings

* Cleanead up code mandated by rubocop

* Completed implementation for signin and added the one for signup

* Fixed issue with rubocop

* Renamed customer_name to lb_user

* Renamed lb_user -> user_domain, fixed issue with signup controller, email verification WAS NOT implemented

* Completed implementation of email_verification

* Fixed rubocop issue

* Final update

* Fix for test with loadbalancer

* Make sure loadbalancer mockup is only used when env defined

* Fix for test on rooms_controller

* Fixed most of the test failing on multitenant env

* Fixed issue detected by rubocop

* Fixed issue with activation tockens not working on resend

* Fixed new issue found by rubocop

* Updated travis script

* Harcoded credentials for mockup

* Updated expectation on start_session

* Fixed issue with duplication of home room

* Updated script for rubocop

* Restored Gemfile
This commit is contained in:
Jesus Federico
2019-04-05 14:54:36 -04:00
committed by GitHub
parent 5ba5b663ac
commit b15868fb3c
28 changed files with 354 additions and 293 deletions

View File

@ -16,13 +16,15 @@
# You should have received a copy of the GNU Lesser General Public License along
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
require 'bbb_api'
class User < ApplicationRecord
include ::APIConcern
include ::BbbApi
attr_accessor :reset_token, :activation_token
after_create :create_home_room_if_verified
attr_accessor :reset_token
after_create :initialize_main_room
before_save { email.try(:downcase!) }
before_create :create_activation_digest
before_destroy :destroy_rooms
@ -125,8 +127,11 @@ class User < ApplicationRecord
def activate
update_attribute(:email_verified, true)
update_attribute(:activated_at, Time.zone.now)
end
initialize_main_room
def activated?
return true unless Rails.configuration.enable_email_verification
email_verified
end
def send_activation_email(url)
@ -180,7 +185,17 @@ class User < ApplicationRecord
end
def greenlight_account?
provider == "greenlight"
return provider == "greenlight" unless Rails.configuration.loadbalanced_configuration
# No need to retrive the provider info if the provider is whitelisted
return true if launcher_allow_user_signup_whitelisted?(provider)
# Proceed with fetching the provider info
provider_info = retrieve_provider_info(provider, 'api2', 'getUserGreenlightCredentials')
provider_info['provider'] == 'greenlight'
end
def activation_token
# Create the token.
create_reset_activation_digest(User.new_token)
end
def self.digest(string)
@ -195,10 +210,11 @@ class User < ApplicationRecord
private
def create_activation_digest
# Create the token and digest.
self.activation_token = User.new_token
self.activation_digest = User.digest(activation_token)
def create_reset_activation_digest(token)
# Create the digest and persist it.
self.activation_digest = User.digest(token)
save
token
end
# Destory a users rooms when they are removed.
@ -206,16 +222,9 @@ class User < ApplicationRecord
rooms.destroy_all
end
# Assigns the user a BigBlueButton id and a home room if verified
def create_home_room_if_verified
self.uid = "gl-#{(0...12).map { (65 + rand(26)).chr }.join.downcase}"
initialize_main_room if email_verified
save
end
# Initializes a room for the user and assign a BigBlueButton user id.
def initialize_main_room
self.uid = "gl-#{(0...12).map { (65 + rand(26)).chr }.join.downcase}"
self.main_room = Room.create!(owner: self, name: I18n.t("home_room"))
save
end