Class: StandardId::Web::SignupForm

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Attributes, ActiveModel::Model
Defined in:
app/forms/standard_id/web/signup_form.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#accountObject (readonly)

Returns the value of attribute account.



11
12
13
# File 'app/forms/standard_id/web/signup_form.rb', line 11

def 
  @account
end

Instance Method Details

#submitObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/forms/standard_id/web/signup_form.rb', line 16

def submit
  return false unless valid?

  

  ActiveRecord::Base.transaction do
    @account = Account.create!()

    password_credential = StandardId::PasswordCredential.create!(
      password_credential_params.merge(
        credential_attributes: {
          identifier_attributes: email_identifier_params.merge(account: @account)
        }
      )
    )

    
    emit_credential_created(password_credential)
  end

  true
rescue ActiveRecord::RecordInvalid => e
  errors.add(:base, e.record.errors.full_messages.join(", "))
  false
rescue ActiveRecord::RecordNotUnique => e
  errors.add(:base, e.message)
  false
end