forked from External/greenlight
Merge branch 'master' of github.com:blindsidenetworks/greenlight
This commit is contained in:
@ -5,3 +5,9 @@
|
||||
// Bootstrap
|
||||
@import "bootstrap-sprockets";
|
||||
@import "bootstrap";
|
||||
|
||||
.room {
|
||||
.room-link {
|
||||
margin: 0 auto;
|
||||
}
|
||||
}
|
||||
|
@ -16,4 +16,16 @@ class LandingController < ApplicationController
|
||||
end
|
||||
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
|
||||
|
@ -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
|
||||
|
||||
|
@ -2,8 +2,17 @@ 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
|
||||
|
||||
def room_url
|
||||
"/rooms/#{username}"
|
||||
end
|
||||
end
|
||||
|
@ -45,21 +45,21 @@
|
||||
</div>
|
||||
|
||||
<div id="landing_page_footer_oauth_append">
|
||||
<% if current_user.nil? %>
|
||||
<p>You can have a personal URL (with recordings) by signing in below</p>
|
||||
<ul>
|
||||
<li><%= link_to 'Twitter', '/auth/twitter' %></li>
|
||||
<li><%= link_to 'Google', '/auth/google' %></li>
|
||||
</ul>
|
||||
<% else %>
|
||||
<div>Hello <%= current_user.name %></div>
|
||||
<div><%= link_to 'Personal Room', current_user.room_url %></div>
|
||||
<div><%= link_to 'Logout', '/logout' %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<% if current_user.nil? %>
|
||||
<ul>
|
||||
<li><%= link_to 'Twitter', '/auth/twitter' %></li>
|
||||
<li><%= link_to 'Google', '/auth/google' %></li>
|
||||
</ul>
|
||||
<% else %>
|
||||
<div>Hello <%= current_user.name %></div>
|
||||
<%= link_to 'Logout', '/logout' %>
|
||||
<% end %>
|
||||
|
19
app/views/landing/room.html.erb
Normal file
19
app/views/landing/room.html.erb
Normal file
@ -0,0 +1,19 @@
|
||||
<div class="page-wrapper room">
|
||||
<div class="row">
|
||||
<div class="col-sm-2 col-sm-offset-10">
|
||||
<% if admin? %>
|
||||
<span class="user"><%= current_user.name %></span>
|
||||
<%= link_to "Logout", "/logout" %>
|
||||
<% else %>
|
||||
<%= link_to "Login", "/auth/twitter" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-4 col-sm-offset-4">
|
||||
<div class="room-link">
|
||||
Room Link: <%= link_to "/rooms/#{@room_name}", "/rooms/#{@room_name}" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -16,10 +16,10 @@
|
||||
<!-- Header -->
|
||||
<div class='navbar'>
|
||||
<div class='container'>
|
||||
<%= image_tag "bbb-logo.png", :alt => "BigBlueButton Demo", :class => "center-block" %>
|
||||
<%= link_to image_tag("bbb-logo.png", :alt => "BigBlueButton Demo", :class => "center-block"), root_path %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<%= yield %>
|
||||
</body>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user