Sha256: a3fa3b93b687d8afd0cb16045a043941f2d608db90337e38ee3a7ae6f180cfdb

Contents?: true

Size: 930 Bytes

Versions: 3

Compression:

Stored size: 930 Bytes

Contents

class ActionController::Base

  before_filter { 
    @current_user_manager = OpenStax::Connect::CurrentUserManager.new(request, 
                                                                      session, 
                                                                      cookies) 
  }

  # Returns the current app user
  def current_user
    @current_user_manager.current_user
  end

  # Signs in the given user; the argument can be either a connect user or
  # an app user
  def sign_in(user)
    @current_user_manager.sign_in(user)
  end

  # Signs out the current user
  def sign_out!
    @current_user_manager.sign_out!
  end

  # Returns true iff there is a user signed in
  def signed_in?
    @current_user_manager.signed_in?
  end

  # Useful in before_filters
  def authenticate_user!
    redirect_to openstax_connect.login_path unless signed_in?
  end

protected

  helper_method :current_user, :signed_in?

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
openstax_connect-0.0.6 config/initializers/02_extend_builtins.rb
openstax_connect-0.0.5 config/initializers/02_extend_builtins.rb
openstax_connect-0.0.4 config/initializers/02_extend_builtins.rb