adopt-a-hydrant/app/controllers/sessions_controller.rb

22 lines
558 B
Ruby
Raw Normal View History

2011-03-06 18:28:00 +00:00
class SessionsController < Devise::SessionsController
2011-04-04 04:18:59 +00:00
def new
render("new", :layout => "info_window")
end
2011-03-06 18:28:00 +00:00
def create
resource = warden.authenticate(:scope => resource_name)
2011-03-07 02:40:29 +00:00
if resource
sign_in(resource_name, resource)
2011-04-03 13:56:51 +00:00
render(:json => resource)
2011-03-07 02:40:29 +00:00
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