Class: Macros::Auth::Authenticate

Inherits:
Base
  • Object
show all
Defined in:
lib/macros/auth/authenticate.rb

Overview

Authenticates the given user using warden. This code run at the rack level, and is tied to the request.

Instance Method Summary collapse

Methods inherited from Base

register

Constructor Details

#initializeMacro::Auth::SignIn

Returns step macro instance.



9
# File 'lib/macros/auth/authenticate.rb', line 9

def initialize; end

Instance Method Details

#call(ctx, scope:, warden:) ⇒ Object

Performs a step by authenticating the the given user

Parameters:

  • ctx (Trailblazer::Skill)

    tbl context hash



13
14
15
16
17
18
19
20
21
# File 'lib/macros/auth/authenticate.rb', line 13

def call(ctx, scope:, warden:, **)
  user = warden.authenticate(scope: scope)
  if user
    ctx[:model] = user
    true
  else
    false
  end
end