diff --git a/app/assets/stylesheets/landing.scss b/app/assets/stylesheets/landing.scss index 0dbe3ca0..3bcfc498 100644 --- a/app/assets/stylesheets/landing.scss +++ b/app/assets/stylesheets/landing.scss @@ -5,3 +5,9 @@ // Bootstrap @import "bootstrap-sprockets"; @import "bootstrap"; + +.room { + .room-link { + margin: 0 auto; + } +} diff --git a/app/controllers/landing_controller.rb b/app/controllers/landing_controller.rb index b02805b7..08c3ff30 100644 --- a/app/controllers/landing_controller.rb +++ b/app/controllers/landing_controller.rb @@ -5,4 +5,17 @@ class LandingController < ApplicationController @meeting_token = params[:id] || @meeting_token = rand.to_s[2..10] @meeting_url = meeting_url(@meeting_token) end + + def room + @room_name = params[:name] + @user = User.find_by(username: @room_name) + if @user.nil? + redirect_to root_path + end + end + + def admin? + @user == current_user + end + helper_method :admin? end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index e2ab24aa..83820889 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -2,9 +2,9 @@ class SessionsController < ApplicationController def create @user = User.from_omniauth(request.env['omniauth.auth']) session[:user_id] = @user.id + redirect_to controller: 'landing', action: 'room', name: @user.username rescue => e logger.error "Error authenticating via omniauth: #{e}" - ensure redirect_to root_path end diff --git a/app/models/user.rb b/app/models/user.rb index 80c35a02..0941600e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,8 +2,13 @@ class User < ApplicationRecord def self.from_omniauth(auth_hash) user = find_or_create_by(uid: auth_hash['uid'], provider: auth_hash['provider']) + user.username = self.send("#{auth_hash['provider']}_username", auth_hash) rescue nil user.name = auth_hash['info']['name'] user.save! user end + + def self.twitter_username(auth_hash) + auth_hash['info']['nickname'] + end end diff --git a/app/views/landing/room.html.erb b/app/views/landing/room.html.erb new file mode 100644 index 00000000..fc853c47 --- /dev/null +++ b/app/views/landing/room.html.erb @@ -0,0 +1,19 @@ +