Class: JwtAuthEngine::ChangePasswordService

Inherits:
BaseService
  • Object
show all
Defined in:
app/services/jwt_auth_engine/change_password_service.rb

Overview

Changes password for an authenticated auth model record.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseService

#failure, #success

Constructor Details

#initialize(auth_model_instance:, change_password_params:) ⇒ ChangePasswordService

Returns a new instance of ChangePasswordService.



8
9
10
11
12
13
# File 'app/services/jwt_auth_engine/change_password_service.rb', line 8

def initialize(auth_model_instance:, change_password_params:)
  @auth_model_instance = auth_model_instance
  @current_password = change_password_params[JwtAuthEngine.current_password_field]
  @new_password = change_password_params[JwtAuthEngine.new_password_field]
  super()
end

Instance Attribute Details

#auth_model_instanceObject (readonly)

Returns the value of attribute auth_model_instance.



6
7
8
# File 'app/services/jwt_auth_engine/change_password_service.rb', line 6

def auth_model_instance
  @auth_model_instance
end

#current_passwordObject (readonly)

Returns the value of attribute current_password.



6
7
8
# File 'app/services/jwt_auth_engine/change_password_service.rb', line 6

def current_password
  @current_password
end

#new_passwordObject (readonly)

Returns the value of attribute new_password.



6
7
8
# File 'app/services/jwt_auth_engine/change_password_service.rb', line 6

def new_password
  @new_password
end

Instance Method Details

#callObject



15
16
17
18
19
20
# File 'app/services/jwt_auth_engine/change_password_service.rb', line 15

def call
  return failure(invalid: required_fields_message) if missing_password_fields?
  return failure(invalid: incorrect_password_message) unless current_password_valid?

  update_password
end