Sha256: b2ce1033c09446c201934bcbe56c478b74b561b13c8127f69941d0b01ff636e7

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 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 = sso_clyent_user_klass.send("find_by_#{sso_clyent_userid}", omniauth['uid'])
      user.respond_to?(:save) ? user.save : user.update
    else
      # New user registration
      user = sso_clyent_user_klass.create({:"#{sso_clyent_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

2 entries across 2 versions & 1 rubygems

Version Path
sso_clyent-0.1.0 app/controllers/sso_clyent/user_sessions_controller.rb
sso_clyent-0.0.7.38 app/controllers/sso_clyent/user_sessions_controller.rb