summaryrefslogtreecommitdiff
path: root/users/app/controllers/sessions_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'users/app/controllers/sessions_controller.rb')
-rw-r--r--users/app/controllers/sessions_controller.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/users/app/controllers/sessions_controller.rb b/users/app/controllers/sessions_controller.rb
index e68d798..284c0e2 100644
--- a/users/app/controllers/sessions_controller.rb
+++ b/users/app/controllers/sessions_controller.rb
@@ -8,16 +8,20 @@ class SessionsController < ApplicationController
def create
@user = User.find_by_param(params[:login])
session[:handshake] = @user.initialize_auth(params['A'].hex)
- render :json => { :B => session[:handshake].bb.to_s(16) }
+ User.current = @user #?
+ render :json => session[:handshake]
rescue RECORD_NOT_FOUND
render :json => {:errors => {:login => ["unknown user"]}}
end
def update
+ # TODO: validate the id belongs to the session
@user = User.find_by_param(params[:id])
- @server_auth = @user.authenticate!(params[:client_auth].hex, session.delete(:handshake))
+ @srp_session = session.delete(:handshake)
+ @srp_session.authenticate!(params[:client_auth].hex)
session[:user_id] = @user.id
- render :json => {:M2 => @server_auth}
+ User.current = @user #?
+ render :json => @srp_session
rescue WRONG_PASSWORD
session[:handshake] = nil
render :json => {:errors => {"password" => ["wrong password"]}}
@@ -25,6 +29,7 @@ class SessionsController < ApplicationController
def destroy
session[:user_id] = nil
+ User.current = nil #?
redirect_to root_path
end
end