forked from External/greenlight
Merge branch 'master' of github.com:blindsidenetworks/greenlight
This commit is contained in:
@ -4,4 +4,9 @@ require 'digest/sha1'
|
||||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery with: :exception
|
||||
include ApplicationHelper
|
||||
|
||||
def current_user
|
||||
@current_user ||= User.find_by(id: session[:user_id])
|
||||
end
|
||||
helper_method :current_user
|
||||
end
|
||||
|
17
app/controllers/sessions_controller.rb
Normal file
17
app/controllers/sessions_controller.rb
Normal file
@ -0,0 +1,17 @@
|
||||
class SessionsController < ApplicationController
|
||||
def create
|
||||
@user = User.from_omniauth(request.env['omniauth.auth'])
|
||||
session[:user_id] = @user.id
|
||||
rescue => e
|
||||
logger.error "Error authenticating via omniauth: #{e}"
|
||||
ensure
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
def destroy
|
||||
if current_user
|
||||
session.delete(:user_id)
|
||||
end
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
@ -4,7 +4,7 @@ module BbbHelper
|
||||
if !bbb
|
||||
return { :returncode => false, :messageKey => "BBBAPICallInvalid", :message => "BBB API call invalid." }
|
||||
else
|
||||
meeting_id = (Digest::SHA1.hexdigest("Rails.application.secrets.secret_key_base"+meeting_token)).to_s
|
||||
meeting_id = (Digest::SHA1.hexdigest(Rails.application.secrets[:secret_key_base]+meeting_token)).to_s
|
||||
|
||||
#See if the meeting is running
|
||||
begin
|
||||
|
9
app/models/user.rb
Normal file
9
app/models/user.rb
Normal file
@ -0,0 +1,9 @@
|
||||
class User < ApplicationRecord
|
||||
|
||||
def self.from_omniauth(auth_hash)
|
||||
user = find_or_create_by(uid: auth_hash['uid'], provider: auth_hash['provider'])
|
||||
user.name = auth_hash['info']['name']
|
||||
user.save!
|
||||
user
|
||||
end
|
||||
end
|
@ -66,3 +66,13 @@ $(document).ready(function($) {
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<% 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 %>
|
||||
|
Reference in New Issue
Block a user