Class: Monban::UseCase::Auth::Verify::Authy

Inherits:
Base
  • Object
show all
Defined in:
lib/monban/use_case/auth/verify/authy.rb

Instance Method Summary collapse

Instance Method Details

#verify(params) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/monban/use_case/auth/verify/authy.rb', line 20

def verify(params)
  Getto::Params.new.validate(params) do |v|
    v.hash(
      account_id:  v.integer                         {|val| param_error!(account_id: val) },
      authy_token: v.combine([v.string, v.not_empty]){|val| param_error!(authy_token: val) },
    )
  end or param_error!(params: params)

  authy_id = repository.authy_id(
    account_id: params[:account_id],
  ) or error.invalid_account! "account_id: #{params[:account_id]}"

  authy.verify(
    authy_id:    authy_id,
    authy_token: params[:authy_token],
  ) or error.invalid_account! "authy_token unmatched: #{authy_id}/#{params[:authy_token]}"

  nil
end