summaryrefslogtreecommitdiff
path: root/app/models/account.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/account.rb')
-rw-r--r--app/models/account.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index af470ed..a5cd833 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -1,7 +1,7 @@
#
-# The Account model takes care of the livecycle of a user.
+# The Account model takes care of the lifecycle of a user.
# It composes a User record and it's identity records.
-# It also allows for other engines to hook into the livecycle by
+# It also allows for other engines to hook into the lifecycle by
# monkeypatching the create, update and destroy methods.
# There's an ActiveSupport load_hook at the end of this file to
# make this more easy.
@@ -20,6 +20,7 @@ class Account
user = nil
user = User.new(attrs)
user.save
+
if !user.tmp? && user.persisted?
identity = user.identity
identity.user_id = user.id
@@ -27,6 +28,12 @@ class Account
identity.errors.each do |attr, msg|
user.errors.add(attr, msg)
end
+
+ if APP_CONFIG[:invite_required]
+ user_invite_code = InviteCode.find_by_invite_code user.invite_code
+ user_invite_code.invite_count += 1
+ user_invite_code.save
+ end
end
rescue StandardError => ex
user.errors.add(:base, ex.to_s) if user