module Devbootcamp::Rails::AuthenticationConcern

Private Instance Methods

authenticated?() click to toggle source
# File lib/devbootcamp/rails/authentication_concern.rb, line 24
def authenticated?
  session[:oauth_token].is_a?(Hash)
end
current_user() click to toggle source
# File lib/devbootcamp/rails/authentication_concern.rb, line 37
def current_user
  return nil unless authenticated?
  return @current_user if @current_user
  @current_user = Devbootcamp::User.new(session[:current_user_attributes])
end
current_user=(current_user) click to toggle source
# File lib/devbootcamp/rails/authentication_concern.rb, line 32
def current_user= current_user
  @current_user = current_user
  session[:current_user_attributes] = current_user.attributes
end
devbootcamp_oauth_authorize_url() click to toggle source
# File lib/devbootcamp/rails/authentication_concern.rb, line 43
def devbootcamp_oauth_authorize_url
  Devbootcamp::OAuth.authorize_url
end
devbootcamp_oauth_unauthorize_url() click to toggle source
# File lib/devbootcamp/rails/authentication_concern.rb, line 47
def devbootcamp_oauth_unauthorize_url
  Devbootcamp::OAuth.unauthorize_url :redirect_uri => root_url
end
ensure_authenticated!() click to toggle source
# File lib/devbootcamp/rails/authentication_concern.rb, line 19
def ensure_authenticated!
  return if authenticated?
  redirect_to sign_in_path(r:request.url)
end
set_oauth_token!() click to toggle source
# File lib/devbootcamp/rails/authentication_concern.rb, line 14
def set_oauth_token!
  Devbootcamp::OAuth.callback_url = oauth_callback_url
  Devbootcamp::OAuth.token_from_hash(session[:oauth_token])
end
unauthenticate!() click to toggle source
# File lib/devbootcamp/rails/authentication_concern.rb, line 28
def unauthenticate!
  session.clear
end