Sha256: e9e4835e2d7b3037d3c2a165a363876171f942205ed1a29763e3c2ea5f50572a

Contents?: true

Size: 884 Bytes

Versions: 15

Compression:

Stored size: 884 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 = @user.sessions.create!
      cookies.signed.permanent[:session_token] = { value: session.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

15 entries across 15 versions & 1 rubygems

Version Path
authentication-zero-2.16.28 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-2.16.27 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-2.16.26 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-2.16.25 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-2.16.24 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-2.16.23 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-2.16.22 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-2.16.21 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-2.16.20 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-2.16.19 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-2.16.18 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-2.16.17 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-2.16.16 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-2.16.15 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
authentication-zero-2.16.14 lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt