Class: StandardId::Oauth::PasswordFlow

Inherits:
TokenGrantFlow show all
Defined in:
lib/standard_id/oauth/password_flow.rb

Constant Summary collapse

DUMMY_PASSWORD_DIGEST =
Concurrent::Delay.new { BCrypt::Password.create("").freeze }

Instance Attribute Summary

Attributes inherited from TokenGrantFlow

#params, #request

Attributes inherited from BaseRequestFlow

#current_account, #params, #request

Instance Method Summary collapse

Methods inherited from TokenGrantFlow

#execute, extra_permitted_keys, #initialize

Methods inherited from BaseRequestFlow

expect_params, expected_params, extra_permitted_keys, #initialize, permit_params, permitted_params

Constructor Details

This class inherits a constructor from StandardId::Oauth::TokenGrantFlow

Instance Method Details

#authenticate!Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/standard_id/oauth/password_flow.rb', line 11

def authenticate!
  validate_client_secret!(params[:client_id], params[:client_secret]) if params[:client_secret].present?
  emit_authentication_started

  @account = (params[:username], params[:password])

  if @account.blank?
    emit_authentication_failed
    raise StandardId::InvalidGrantError, "Invalid username or password"
  end

  emit_password_validated
  validate_requested_scope!
end