summaryrefslogtreecommitdiff
path: root/users
diff options
context:
space:
mode:
authorjessib <jessib@riseup.net>2012-10-02 15:29:28 -0700
committerjessib <jessib@riseup.net>2012-10-02 15:29:28 -0700
commit5bc3eae400754dda90a45d6953a02a069a1c0285 (patch)
tree9391b3bb5c3f0847746b52805c61ea346486301a /users
parent61d73ac517ccbcc7ca8892010ef89e861052807f (diff)
Some more tweaks to help ticket models. Still want to tweak current_user access from users engine.
Diffstat (limited to 'users')
-rw-r--r--users/app/controllers/sessions_controller.rb6
-rw-r--r--users/app/models/user.rb7
2 files changed, 13 insertions, 0 deletions
diff --git a/users/app/controllers/sessions_controller.rb b/users/app/controllers/sessions_controller.rb
index e68d798..d398057 100644
--- a/users/app/controllers/sessions_controller.rb
+++ b/users/app/controllers/sessions_controller.rb
@@ -8,6 +8,7 @@ class SessionsController < ApplicationController
def create
@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) }
rescue RECORD_NOT_FOUND
render :json => {:errors => {:login => ["unknown user"]}}
@@ -17,6 +18,7 @@ class SessionsController < ApplicationController
@user = User.find_by_param(params[:id])
@server_auth = @user.authenticate!(params[:client_auth].hex, session.delete(:handshake))
session[:user_id] = @user.id
+ User.current = @user #?
render :json => {:M2 => @server_auth}
rescue WRONG_PASSWORD
session[:handshake] = nil
@@ -25,6 +27,10 @@ class SessionsController < ApplicationController
def destroy
session[:user_id] = nil
+ User.current = nil #?
redirect_to root_path
end
+
+
+
end
diff --git a/users/app/models/user.rb b/users/app/models/user.rb
index fa64f42..95ee810 100644
--- a/users/app/models/user.rb
+++ b/users/app/models/user.rb
@@ -46,4 +46,11 @@ class User < CouchRest::Model::Base
password_verifier.hex
end
+ def self.current
+ Thread.current[:user]
+ end
+ def self.current=(user)
+ Thread.current[:user] = user
+ end
+
end