summaryrefslogtreecommitdiff
path: root/example/models/user.rb
diff options
context:
space:
mode:
Diffstat (limited to 'example/models/user.rb')
-rw-r--r--example/models/user.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/example/models/user.rb b/example/models/user.rb
index daea621..ffbdf62 100644
--- a/example/models/user.rb
+++ b/example/models/user.rb
@@ -19,11 +19,20 @@ class User
end
def initialize_auth(params)
- srp = SRP::Server.new(self.salt, self.verifier)
- bb, u = srp.initialize_auth(params.delete('aa').to_i)
- return {:bb => bb, :u => u}
+ self.srp = SRP::Server.new(self.salt, self.verifier)
+ bb, u = self.srp.initialize_auth(params.delete('A').to_i)
+ return {:B => bb, :u => u}
end
+ def authenticate(params)
+ if m2 = self.srp.authenticate(params.delete('aa').to_i, params.delete('M').to_i)
+ return {:M2 => m2}
+ else
+ return {:error => "Access Denied"}
+ end
+ end
+
+
def login!(params)
self.active = valid_login?(params[:login], params[:password])
end