summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorankonym <ankonym@gmail.com>2015-09-21 18:34:04 +0200
committerankonym <ankonym@gmail.com>2015-09-28 15:12:46 +0200
commit9adbde13619de8b2c300056b062d12f0961cb710 (patch)
treef9161d0a39b497cca05887a0e4fc48acde5aa650 /app/models
parentca591b482870c93674aaf454e90f56796da7d87d (diff)
Make invite code configurable
Through the config param 'invite_required', providers can decide whether users need to provide an invite code upon signup. The default setting is false.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/account.rb9
-rw-r--r--app/models/user.rb2
2 files changed, 7 insertions, 4 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index c398d93..a5cd833 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -28,9 +28,12 @@ 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
+
+ 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
diff --git a/app/models/user.rb b/app/models/user.rb
index c0079d5..3daee0f 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -40,7 +40,7 @@ class User < CouchRest::Model::Base
:mx_with_fallback => true
- validates_with InviteCodeValidator, on: :create
+ validates_with InviteCodeValidator, on: :create, if: -> {APP_CONFIG[:invite_required]}
timestamps!