Sha256: f6896867b433a61bd91b7975b865f78dfd193d9d311fa95f08960a3f8b7ea177

Contents?: true

Size: 736 Bytes

Versions: 3

Compression:

Stored size: 736 Bytes

Contents

class SessionsController < ApplicationController

  skip_before_filter :verify_authenticity_token, only: [:new, :create], if: Rails.env.development?
  before_filter :authenticate!, only: :new

  def new
    redirect_to(session.delete( :return_to ) || root_path)
  end

  def create
    self.current_user = User.update_or_create_with_omniauth_aai(auth_hash)

    flash[:notice] = "Login successful"

    redirect_to(session.delete( :return_to ) || root_path)
  end

  def failure
    flash[:error] = "Login failed"
    redirect_to(root_path)
  end

  def destroy
    self.current_user = nil
    flash[:notice] = "Logout successful"
    redirect_to(root_path)
  end

  private

  def auth_hash
    request.env['omniauth.auth']
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
omniauth-aai-0.6.9 spec/example_rails4_app/app/controllers/sessions_controller.rb
omniauth-aai-0.6.8 spec/example_rails4_app/app/controllers/sessions_controller.rb
omniauth-aai-0.6.6 spec/example_rails4_app/app/controllers/sessions_controller.rb