summaryrefslogtreecommitdiff
path: root/users/config
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-11-09 16:45:54 +0100
committerAzul <azul@leap.se>2012-11-09 16:45:54 +0100
commit5b300b554682c232c0955bdb0dd3d8263dde901e (patch)
treee27fe040bfaba5840730f466d4c6f90213759d5e /users/config
parent63c5b2cafdefbd9b13297faa57ee2f18a5c07bf5 (diff)
seperated the warden classes from the initializer
also commented the sessions controller test a bit and fixed it
Diffstat (limited to 'users/config')
-rw-r--r--users/config/initializers/warden.rb61
1 files changed, 0 insertions, 61 deletions
diff --git a/users/config/initializers/warden.rb b/users/config/initializers/warden.rb
index 11b950f..45feb6c 100644
--- a/users/config/initializers/warden.rb
+++ b/users/config/initializers/warden.rb
@@ -5,64 +5,3 @@ end
RailsWarden.unauthenticated_action = :new
-# Setup Session Serialization
-class Warden::SessionSerializer
- def serialize(record)
- [record.class.name, record.id]
- end
-
- def deserialize(keys)
- klass, id = keys
- klass.constantize.find(id)
- end
-end
-
-Warden::Strategies.add(:secure_remote_password) do
-
- def valid?
- handshake? || authentication?
- end
-
- def authenticate!
- if authentication?
- validate!
- else # handshake
- initialize!
- end
- end
-
- protected
-
- def handshake?
- params['A'] && params['login']
- end
-
- def authentication?
- params['client_auth'] && session[:handshake]
- end
-
- def validate!
- user = session[:handshake].authenticate(params['client_auth'].hex)
- user ? success!(user) : fail!(:password => "Could not log in")
- end
-
- def initialize!
- user = User.find_by_param(id)
- session[:handshake] = user.initialize_auth(params['A'].hex)
- custom! json_response(session[:handshake])
- rescue RECORD_NOT_FOUND
- fail! :login => "User not found!"
- end
-
- def json_response(object)
- [ 200,
- {"Content-Type" => "application/json; charset=utf-8"},
- [object.to_json]
- ]
- end
-
- def id
- params["id"] || params["login"]
- end
-end
-