2011-03-06 18:28:00 +00:00
|
|
|
class SessionsController < Devise::SessionsController
|
|
|
|
respond_to :json
|
|
|
|
|
|
|
|
def create
|
|
|
|
resource = warden.authenticate(:scope => resource_name)
|
2011-03-07 02:40:29 +00:00
|
|
|
if resource
|
|
|
|
sign_in(resource_name, resource)
|
|
|
|
respond_with resource
|
|
|
|
else
|
|
|
|
render(:json => {"errors" => {:password => ["You need to sign in or sign up before continuing."]}})
|
|
|
|
end
|
2011-03-06 18:28:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
signed_in = signed_in?(resource_name)
|
|
|
|
sign_out(resource_name) if signed_in
|
2011-03-07 02:40:29 +00:00
|
|
|
render(:json => {"success" => signed_in})
|
2011-03-06 18:28:00 +00:00
|
|
|
end
|
|
|
|
end
|