Reverts unwanted changes

This commit is contained in:
Nithin David Thomas
2024-02-14 20:33:34 +05:30
parent 55317c8fad
commit 54bd3c38d5
3 changed files with 7 additions and 3 deletions
+3 -3
View File
@@ -2,7 +2,7 @@
class AccountBuilder
include CustomExceptions::Account
pattr_initialize [:email!, :confirmed, :user, :user_password, :super_admin, :locale]
pattr_initialize [:account_name, :email!, :confirmed, :user, :user_full_name, :user_password, :super_admin, :locale]
def perform
if @user.nil?
@@ -49,7 +49,7 @@ class AccountBuilder
end
def create_account
@account = Account.create!(name: '', locale: I18n.locale)
@account = Account.create!(name: account_name, locale: I18n.locale)
Current.account = @account
end
@@ -74,7 +74,7 @@ class AccountBuilder
@user = User.new(email: @email,
password: user_password,
password_confirmation: user_password,
name: '')
name: user_full_name)
@user.type = 'SuperAdmin' if @super_admin
@user.confirm if @confirmed
@user.save!
@@ -23,6 +23,8 @@ class Api::V1::AccountsController < Api::BaseController
def create
@user, @account = AccountBuilder.new(
account_name: account_params[:account_name],
user_full_name: account_params[:user_full_name],
email: account_params[:email],
user_password: account_params[:password],
locale: account_params[:locale],
+2
View File
@@ -68,6 +68,8 @@ class User < ApplicationRecord
# work because :validatable in devise overrides this.
# validates_uniqueness_of :email, scope: :account_id
validates :email, presence: true
has_many :account_users, dependent: :destroy_async
has_many :accounts, through: :account_users
accepts_nested_attributes_for :account_users