Sha256: 5d687addd7344a42e3f77c94ba88756fa2fb222b3399cfbd12d8d66114743bc3

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 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.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 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
    session[:user_id] = nil

    flash[:notice] = 'You have successfully signed out!'
    redirect_to "#{OmniAuth::Strategies::Sso._provider[:url]}/logout?callback_url=#{root_url}"
  end

  private
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sso_clyent-0.0.2 app/controllers/sso_clyent/user_sessions_controller.rb