diff options
author | azul <azul@leap.se> | 2015-09-30 10:51:21 +0200 |
---|---|---|
committer | azul <azul@leap.se> | 2015-09-30 10:51:21 +0200 |
commit | d45f6c61f6a13be06f1977b857e0cb31e79c5317 (patch) | |
tree | d3089b334c2663ea2fd76cf62dea853bdd57b047 /app/models/account.rb | |
parent | a894966e425f27c31e7da196658c6ddee3fc3714 (diff) | |
parent | d4f10a8d47572bcab4c44878b952146732d64d2e (diff) |
Merge pull request #194 from Alster-Hamburgers/feature/invite_code
Request for feedback on invite code feature
Diffstat (limited to 'app/models/account.rb')
-rw-r--r-- | app/models/account.rb | 11 |
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 |