Class: Account::Service::Authentication

Inherits:
Object
  • Object
show all
Defined in:
app/models/aikotoba/account/service/authentication.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(email:, password:, account_class: Account, lock_service: Account::Service::Lock, lockable: Account.lockable?, prevent_timing_atack: Aikotoba.prevent_timing_atack) ⇒ Authentication

Returns a new instance of Authentication.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/models/aikotoba/account/service/authentication.rb', line 9

def initialize(email:, password:,
  account_class: Account,
  lock_service: Account::Service::Lock,
  lockable: Account.lockable?,
  prevent_timing_atack: Aikotoba.prevent_timing_atack)
  @account_class = 
  @lock_service = lock_service
  @lockable = lockable
  @email = email
  @password = password
  @aikotoba_prevent_timing_atack = prevent_timing_atack
end

Class Method Details

.call!(email:, password:) ⇒ Object



5
6
7
# File 'app/models/aikotoba/account/service/authentication.rb', line 5

def self.call!(email:, password:)
  new(email: email, password: password).call!
end

Instance Method Details

#call!Object



22
23
24
25
26
27
28
29
30
31
# File 'app/models/aikotoba/account/service/authentication.rb', line 22

def call!
   = find_by_identifier
  return prevent_timing_atack && nil unless 

  authenticate().tap do |result|
    ActiveRecord::Base.transaction do
      result ? success_callback() : failed_callback()
    end
  end
end