summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorankonym <ankonym@gmail.com>2015-08-05 16:55:39 +0200
committerankonym <ankonym@gmail.com>2015-09-28 15:12:44 +0200
commite6e1187fdc44766aa4336e05aa12d4e74db65d1d (patch)
treee065ba55c38515cdd60eec195d2096a720049551
parentea71f09ee23dbc080dd29adf2c3b8fa61f848c22 (diff)
Adding invite code field to signup with validation for hardcoded invite code
-rw-r--r--app/models/user.rb4
-rw-r--r--app/views/users/new.html.haml5
-rw-r--r--test/unit/user_test.rb5
3 files changed, 12 insertions, 2 deletions
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
diff --git a/app/views/users/new.html.haml b/app/views/users/new.html.haml
index 41a9d55..cd4bf70 100644
--- a/app/views/users/new.html.haml
+++ b/app/views/users/new.html.haml
@@ -17,5 +17,8 @@
= f.input :login, :label => t(:username), :required => false, :input_html => { :id => :srp_username }
= f.input :password, :required => false, :validate => true, :input_html => { :id => :srp_password }
= f.input :password_confirmation, :required => false, :validate => true, :input_html => { :id => :srp_password_confirmation }
- = f.button :wrapped, cancel: home_path
+ = f.input :invite_code, :input_html => { :id => :srp_invite_code }
+
+ = f.button :wrapped, cancel: home_path
+-#
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb
index c301923..cd290d5 100644
--- a/test/unit/user_test.rb
+++ b/test/unit/user_test.rb
@@ -70,6 +70,11 @@ class UserTest < ActiveSupport::TestCase
assert_equal key, @user.public_key
end
+ test "user should have an invite token" do
+ user = User.new
+ assert_nil(user.invite_code)
+ end
+
#
## Regression tests
#