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
34
35
36
# 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

  params = params.merge(provider: options['contract.default'].provider) if params[:provider].blank?

  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



42
43
44
# File 'app/concepts/account_cpt/registration/regular_user/with_password.rb', line 42

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

#set_error_messages!(options) ⇒ Object



38
39
40
# File 'app/concepts/account_cpt/registration/regular_user/with_password.rb', line 38

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