Sha256: 65bc440e26773401b4a85f5ea87f7554c24f68785667aa8b392c3387d81b69d7

Contents?: true

Size: 1.1 KB

Versions: 7

Compression:

Stored size: 1.1 KB

Contents

class SsoClyent::UserSessionsController < SsoClyent::ApplicationController
  before_filter :login_required, :only => [ :destroy ]

  respond_to :html

  # omniauth callback method
  def create
    omniauth = env['omniauth.auth']
    logger.debug "+++ #{omniauth}"

    if user = user_klass.send("find_by_#{userid}", omniauth['uid'])
      user.respond_to?(:save) ? user.save : user.update
    else
      # New user registration
      user = user_klass.create({:"#{userid}" => omniauth['uid']})
    end

    # Currently storing all the info
    session[:user_id] = omniauth

    flash[:notice] = "Successfully logged in"
    redirect_to session['return-to-url'] || SsoClyent.after_sign_in_path
  end

  # Omniauth failure callback
  def failure
    flash[:notice] = params[:message]

  end

  # logout - Clear our rack session BUT essentially redirect to the provider
  # to clean up the Devise session from there too !
  def destroy
    current_user_logout

    flash[:notice] = 'You have successfully signed out!'
    redirect_to "#{SsoClyent.logout_url}?callback_url=#{session['return-to-url'] || root_url}"
  end

  private
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sso_clyent-0.0.7.37 app/controllers/sso_clyent/user_sessions_controller.rb
sso_clyent-0.0.7.36 app/controllers/sso_clyent/user_sessions_controller.rb
sso_clyent-0.0.7.35 app/controllers/sso_clyent/user_sessions_controller.rb
sso_clyent-0.0.7.34 app/controllers/sso_clyent/user_sessions_controller.rb
sso_clyent-0.0.7.33 app/controllers/sso_clyent/user_sessions_controller.rb
sso_clyent-0.0.7.32 app/controllers/sso_clyent/user_sessions_controller.rb
sso_clyent-0.0.7.31 app/controllers/sso_clyent/user_sessions_controller.rb