Skip to content

Instantly share code, notes, and snippets.

@benlangfeld
Created August 6, 2010 21:24
Show Gist options
  • Save benlangfeld/512035 to your computer and use it in GitHub Desktop.
Save benlangfeld/512035 to your computer and use it in GitHub Desktop.
POST /user_sessions HTTP/1.1
Content-Type: application/json
{"username":"admin","password":"test","remember":true}
HTTP/1.1 200 OK
Etag: "7666ae547899c0ffa16acfd66371c76e"
Connection: close
Content-Type: text/html; charset=utf-8
Date: Fri, 06 Aug 2010 21:21:22 GMT
Server: WEBrick/1.3.1 (Ruby/1.8.7/2010-04-19)
X-Runtime: 0.171651
Content-Length: 3245
Cache-Control: max-age=0, private, must-revalidate
class UserSessionsController < ApplicationController
filter_resource_access
layout "login"
ssl_required :new, :create if Settings.ssl
respond_to :html, :xml, :json
def new
respond_with @user_session = UserSession.new
end
def create
@user_session = UserSession.new params[:user_session]
if @user_session.save
flash[:notice] = "Successfully logged in."
end
respond_with @user_session#, :location => root_url
end
def destroy
@user_session = UserSession.find
@user_session.destroy
flash[:notice] = "Sucessfully logged out."
redirect_to root_url
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment