Sha256: 6841933a7e9115c10c495f9eb77923b7122aa7e6a4b7354f46833c00dc673973

Contents?: true

Size: 878 Bytes

Versions: 9

Compression:

Stored size: 878 Bytes

Contents

class Kuroko2::SessionsController < Kuroko2::ApplicationController
  skip_before_action :require_sign_in

  def new
    render layout: false
  end

  def create
    return_to = params[:state]
    reset_session

    unless valid_google_hosted_domain?
      render :invalid_hd, status: 403, layout: false
      return
    end

    self.current_user = Kuroko2::User.find_or_create_user(auth_hash[:uid], auth_hash[:info])

    unless Kuroko2::ReturnToValidator.valid?(return_to)
      return_to = root_path
    end
    redirect_to return_to
  end

  def destroy
    reset_session

    redirect_to sign_in_path
  end

  private

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

  def valid_google_hosted_domain?
    hd = Kuroko2.config.app_authentication.google_oauth2.options.hd
    if hd.present?
      hd == auth_hash.extra.id_info.hd
    else
      true
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
kuroko2-0.4.2 app/controllers/kuroko2/sessions_controller.rb
kuroko2-0.4.1 app/controllers/kuroko2/sessions_controller.rb
kuroko2-0.4.0 app/controllers/kuroko2/sessions_controller.rb
kuroko2-0.3.4 app/controllers/kuroko2/sessions_controller.rb
kuroko2-0.3.3 app/controllers/kuroko2/sessions_controller.rb
kuroko2-0.3.2 app/controllers/kuroko2/sessions_controller.rb
kuroko2-0.3.1 app/controllers/kuroko2/sessions_controller.rb
kuroko2-0.3.0 app/controllers/kuroko2/sessions_controller.rb
kuroko2-0.2.3 app/controllers/kuroko2/sessions_controller.rb