diff --git a/Gemfile b/Gemfile index f279f3d3..41da0368 100644 --- a/Gemfile +++ b/Gemfile @@ -47,7 +47,6 @@ gem 'bcrypt', '~> 3.1.7' gem 'omniauth' gem 'omniauth-twitter' gem 'omniauth-google-oauth2' -gem "omniauth-bn-launcher", git: "https://github.com/blindsidenetworks/omniauth-bn-launcher.git" # BigBlueButton API wrapper. gem 'bigbluebutton-api-ruby' @@ -65,6 +64,7 @@ gem 'rubocop', require: false group :production do # Use a postgres database in production. gem 'pg', '~> 0.18' + gem "omniauth-bn-launcher", git: "https://github.com/blindsidenetworks/omniauth-bn-launcher.git", branch: "oauth2" end group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index 14e4fa5b..3646df04 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,9 +1,11 @@ GIT remote: https://github.com/blindsidenetworks/omniauth-bn-launcher.git - revision: 52fbc3ff40c64ad5eef51f7e6c0beba2c666356f + revision: d93b9fa51f920c733618ec4040c93458ff19951f + branch: oauth2 specs: omniauth-bn-launcher (0.1.0) omniauth (~> 1.3, >= 1.3.2) + omniauth-oauth2 (= 1.5.0) GEM remote: https://rubygems.org/ diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 9bdb2e59..b34b6f70 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -7,7 +7,7 @@ class MainController < ApplicationController def index if current_user # Redirect authenticated users to their room. - redirect_to room_path(current_user.room) + redirect_to room_path(current_user.main_room) else # Redirect unauthenticated users to root. #TODO use env? for launcher login endpoint diff --git a/app/models/user.rb b/app/models/user.rb index b45fe32a..019c4d74 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -67,19 +67,19 @@ class User < ApplicationRecord end def bn_launcher_name(auth) - auth['user_info']['username'] + auth['info']['name'] end def bn_launcher_username(auth) - auth['user_info']['username'] + auth['info']['username'] end def bn_launcher_email(auth) - auth['user_info']['email'] + auth['info']['email'] end def bn_launcher_image(auth) - "" + auth['info']['image'] end end diff --git a/bin/start b/bin/start index 93c2bb22..c9f53fa0 100755 --- a/bin/start +++ b/bin/start @@ -1,4 +1,9 @@ #!/bin/bash +while [ "$RAILS_ENV" = "production" ] && ! curl http://$DB_HOST:5432/ 2>&1 | grep '52' +do + echo "Waiting for postgres to start up ..." + sleep 1 +done bundle exec rake db:create bundle exec rake db:migrate diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index 9b0ff26e..2f720226 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -10,8 +10,13 @@ Rails.application.config.omniauth_bn_launcher = (ENV["USE_LOADBALANCED_CONFIGURA # Setup the Omniauth middleware. Rails.application.config.middleware.use OmniAuth::Builder do + if Rails.env.production? + provider :bn_launcher, + client_id: ENV['BN_LAUNCHER_CLIENT_ID'], + client_secret: ENV['BN_LAUNCHER_CLIENT_SECRET'], + client_options: {site: ENV['BN_LAUNCHER_REDIRECT_URI']} + end - provider :bn_launcher, ENV['LAUNCHER_SECRET'], (ENV['LAUNCHER_RELATIVE_URL_ROOT'] || '' + '/login') provider :twitter, ENV['TWITTER_ID'], ENV['TWITTER_SECRET']