Sha256: 0fccb3786962a816df19de1c95053fa966a9c7d16e4d96351efc739aa2b8619a

Contents?: true

Size: 898 Bytes

Versions: 16

Compression:

Stored size: 898 Bytes

Contents

class Sessions::OmniauthController < ApplicationController
  skip_before_action :verify_authenticity_token
  skip_before_action :authenticate

  def create
    @user = User.create_with(user_params).find_or_initialize_by(omniauth_params)

    if @user.save
      session_record = @user.sessions.create!
      cookies.signed.permanent[:session_token] = { value: session_record.id, httponly: true }

      redirect_to root_path, notice: "Signed in successfully"
    else
      redirect_to sign_in_path, alert: "Authentication failed"
    end
  end

  def failure
    redirect_to sign_in_path, alert: params[:message]
  end

  private
    def user_params
      { email: omniauth.info.email, password: SecureRandom.base58, verified: true }
    end

    def omniauth_params
      { provider: omniauth.provider, uid: omniauth.uid }
    end

    def omniauth
      request.env["omniauth.auth"]
    end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
authentication-zero-4.0.3 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-4.0.2 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-4.0.1 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-4.0.0 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-3.0.2 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-3.0.1 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-3.0.0 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-3.0.0.alpha1 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-2.16.36 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-2.16.35 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-2.16.34 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-2.16.33 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-2.16.32 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-2.16.31 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-2.16.30 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-2.16.29 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt