summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/account.rb5
-rw-r--r--app/models/invite_code_validator.rb4
2 files changed, 4 insertions, 5 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index a57e3f7..c398d93 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -19,8 +19,8 @@ class Account
identity = nil
user = nil
user = User.new(attrs)
-
user.save
+
if !user.tmp? && user.persisted?
identity = user.identity
identity.user_id = user.id
@@ -28,6 +28,9 @@ class Account
identity.errors.each do |attr, msg|
user.errors.add(attr, msg)
end
+ user_invite_code = InviteCode.find_by_invite_code user.invite_code
+ user_invite_code.invite_count += 1
+ user_invite_code.save
end
rescue StandardError => ex
user.errors.add(:base, ex.to_s) if user
diff --git a/app/models/invite_code_validator.rb b/app/models/invite_code_validator.rb
index d03d510..127dc57 100644
--- a/app/models/invite_code_validator.rb
+++ b/app/models/invite_code_validator.rb
@@ -8,10 +8,6 @@ class InviteCodeValidator < ActiveModel::Validator
elsif count_greater_than_zero?(user_invite_code.invite_count)
add_error_to_user("This code has already been used", user)
-
- else
- user_invite_code.invite_count += 1
- user_invite_code.save
end
end