From e6e1187fdc44766aa4336e05aa12d4e74db65d1d Mon Sep 17 00:00:00 2001 From: ankonym Date: Wed, 5 Aug 2015 16:55:39 +0200 Subject: Adding invite code field to signup with validation for hardcoded invite code --- app/models/user.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/models/user.rb') diff --git a/app/models/user.rb b/app/models/user.rb index d44df40..5510470 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -8,7 +8,7 @@ class User < CouchRest::Model::Base property :password_salt, String, :accessible => true property :contact_email, String, :accessible => true property :contact_email_key, String, :accessible => true - + property :invite_code, String, :accessible => true property :enabled, TrueClass, :default => true # these will be null by default but we shouldn't ever pull them directly, but only via the methods that will return the full ServiceLevel @@ -39,6 +39,8 @@ class User < CouchRest::Model::Base :email => true, :mx_with_fallback => true + validates :invite_code, inclusion: { in: ["testcode"], message: "%{value} is not a valid invite code" } + timestamps! design do -- cgit v1.2.3 From bd98a2cbb8796039efbffb7039a9bda1cde22dae Mon Sep 17 00:00:00 2001 From: ankonym Date: Thu, 13 Aug 2015 15:29:04 +0200 Subject: Add validation of invite code in user object based on codes in couch db --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/user.rb') diff --git a/app/models/user.rb b/app/models/user.rb index 5510470..06e1a0f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -39,7 +39,7 @@ class User < CouchRest::Model::Base :email => true, :mx_with_fallback => true - validates :invite_code, inclusion: { in: ["testcode"], message: "%{value} is not a valid invite code" } + validates_with InviteCodeValidator timestamps! -- cgit v1.2.3 From 45c3fadd930a474951bd918a50e1ea2b00af75c7 Mon Sep 17 00:00:00 2001 From: ankonym Date: Tue, 25 Aug 2015 14:11:00 +0200 Subject: Make sure codes can only be used once, fix validations We introduced a count on invite codes to make sure that (at the moment) codes can only be used once. (The code will also allow multi-use codes in the future.) Also, some of our validations weren't validating against the correct data, which is now fixed. --- app/models/user.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/models/user.rb') diff --git a/app/models/user.rb b/app/models/user.rb index 06e1a0f..a4dd132 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -39,8 +39,10 @@ class User < CouchRest::Model::Base :email => true, :mx_with_fallback => true + validates_with InviteCodeValidator + timestamps! design do -- cgit v1.2.3 From a8f07fb18518fd95fd701e8c0e550a3cd70520b0 Mon Sep 17 00:00:00 2001 From: ankonym Date: Mon, 31 Aug 2015 17:15:27 +0200 Subject: Fixes for the invite code validator Validation should only happen for new records User invite code was nil for invalid invite codes Adding missing tests --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/user.rb') diff --git a/app/models/user.rb b/app/models/user.rb index a4dd132..c0079d5 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 + validates_with InviteCodeValidator, on: :create timestamps! -- cgit v1.2.3 From 9adbde13619de8b2c300056b062d12f0961cb710 Mon Sep 17 00:00:00 2001 From: ankonym Date: Mon, 21 Sep 2015 18:34:04 +0200 Subject: 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. --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/user.rb') 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! -- cgit v1.2.3