Class: AccountCpt::Registration::RegularUser::WithPassword

Inherits:
Trailblazer::Operation
  • Object
show all
Includes:
ErrorOperationHelper, UserRegistration::MergeGuestBookings
Defined in:
app/concepts/account_cpt/registration/regular_user/with_password.rb

Overview

return registered user

Instance Method Summary collapse

Methods included from UserRegistration::MergeGuestBookings

#remove_customer_guest_booking

Methods included from ErrorOperationHelper

#errors, #merge_errors

Instance Method Details

#register_by_password!(options) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/concepts/account_cpt/registration/regular_user/with_password.rb', line 19

def register_by_password!(options, **)
  params = if options['contract.default.params'].respond_to?(:permit!)
             options['contract.default.params'].permit!
           else
             options['contract.default.params']
           end
  service = ::UserRegistration::UsingPassword.new(params)
  if service.save
    options[OpCons::OPERATION_RESULT] = service.user
    true
  else
    merge_errors { service.user.errors }
    false
  end
end

#reset_user_password!(options) ⇒ Object



44
45
46
# File 'app/concepts/account_cpt/registration/regular_user/with_password.rb', line 44

def reset_user_password!(options, **)
  options[OpCons::MODEL].password = nil
end

#set_error_messages!(options) ⇒ Object

def collect_guest_booking!(options, *)

user_id = options[OpCons::OPERATION_RESULT].id
remove_customer_guest_booking(user_id)

end



40
41
42
# File 'app/concepts/account_cpt/registration/regular_user/with_password.rb', line 40

def set_error_messages!(options, **)
  merge_errors { options[OpCons::CONTRACT_DEFAULT].errors }
end