Sha256: 90d70936ea9599e11274bd0e29d392204a22191b457aef1267956b8cccfeef65
Contents?: true
Size: 1.36 KB
Versions: 4
Compression:
Stored size: 1.36 KB
Contents
# frozen_string_literal: true module Decidim # A command with all the business logic to create a user through the sign up form. class CreateRegistration < Rectify::Command # Public: Initializes the command. # # form - A form object with the params. def initialize(form) @form = form end # Executes the command. Broadcasts these events: # # - :ok when everything is valid. # - :invalid if the form wasn't valid and we couldn't proceed. # # Returns nothing. def call return broadcast(:invalid) if form.invalid? delete_pending_invited_user create_user broadcast(:ok, @user) rescue ActiveRecord::RecordInvalid broadcast(:invalid) end private attr_reader :form def delete_pending_invited_user User.invitation_not_accepted.where(email: form.email).delete_all end def create_user @user = User.create!( email: form.email, name: form.name, nickname: form.nickname, password: form.password, password_confirmation: form.password_confirmation, organization: form.current_organization, tos_agreement: form.tos_agreement, newsletter_notifications_at: form.newsletter_at, email_on_notification: true, accepted_tos_version: form.current_organization.tos_version ) end end end
Version data entries
4 entries across 4 versions & 1 rubygems