diff options
author | Azul <azul@leap.se> | 2012-10-11 12:52:40 +0200 |
---|---|---|
committer | Azul <azul@leap.se> | 2012-10-11 12:52:40 +0200 |
commit | 10441deba145f53604ca3b981374f1ee6619c400 (patch) | |
tree | 90d2a851cd558652121182937a5ec8373722cab0 /users/app/controllers | |
parent | 61d73ac517ccbcc7ca8892010ef89e861052807f (diff) | |
parent | 33ef3d2ac9a03b06ff29f1367c69731a89f1dfc7 (diff) |
Merge branch 'release-0.1.0'
Diffstat (limited to 'users/app/controllers')
-rw-r--r-- | users/app/controllers/sessions_controller.rb | 11 |
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 |