summaryrefslogtreecommitdiff
path: root/users/app/models/session.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-11-22 11:36:25 +0100
committerAzul <azul@leap.se>2012-11-22 11:36:25 +0100
commitcec9ad7c514f2f3c767bd12bfc3df28db4d1a98b (patch)
treec6d1d9cdfe809e26b1aab42a31714bbfa800da90 /users/app/models/session.rb
parent7e5db2a28ba872154e5f5002bb84d149a512e36e (diff)
using client side validations for login
Diffstat (limited to 'users/app/models/session.rb')
-rw-r--r--users/app/models/session.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/users/app/models/session.rb b/users/app/models/session.rb
new file mode 100644
index 0000000..a9fdb1b
--- /dev/null
+++ b/users/app/models/session.rb
@@ -0,0 +1,34 @@
+class Session < SRP::Session
+ include ActiveModel::Validations
+
+ attr_accessor :login
+
+ validates :login,
+ :presence => true,
+ :format => { :with => /\A[A-Za-z\d_]+\z/,
+ :message => "Only letters, digits and _ allowed" }
+
+ def initialize(user = nil, aa = nil)
+ super(user, aa) if user
+ end
+
+ def persisted?
+ false
+ end
+
+ def new_record?
+ true
+ end
+
+ def to_model
+ self
+ end
+
+ def to_key
+ [object_id]
+ end
+
+ def to_param
+ nil
+ end
+end