From c2d5a80b576ffc5f9ff0807c9a52fec8b4f34123 Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 5 Oct 2012 16:47:19 +0200 Subject: ruby-srp 0.1.1 has to_json method - simplifies controller --- users/app/controllers/sessions_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'users/app/controllers') diff --git a/users/app/controllers/sessions_controller.rb b/users/app/controllers/sessions_controller.rb index b8043f5..284c0e2 100644 --- a/users/app/controllers/sessions_controller.rb +++ b/users/app/controllers/sessions_controller.rb @@ -9,7 +9,7 @@ class SessionsController < ApplicationController @user = User.find_by_param(params[:login]) session[:handshake] = @user.initialize_auth(params['A'].hex) User.current = @user #? - render :json => { :B => session[:handshake].bb.to_s(16), :salt => @user.password_salt } + render :json => session[:handshake] rescue RECORD_NOT_FOUND render :json => {:errors => {:login => ["unknown user"]}} end @@ -18,10 +18,10 @@ class SessionsController < ApplicationController # TODO: validate the id belongs to the session @user = User.find_by_param(params[:id]) @srp_session = session.delete(:handshake) - @server_auth = @srp_session.authenticate!(params[:client_auth].hex) + @srp_session.authenticate!(params[:client_auth].hex) session[:user_id] = @user.id User.current = @user #? - render :json => {:M2 => "%064x" % @server_auth} + render :json => @srp_session rescue WRONG_PASSWORD session[:handshake] = nil render :json => {:errors => {"password" => ["wrong password"]}} -- cgit v1.2.3