Created
August 23, 2011 19:42
-
-
Save joslynesser/1166279 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST /user_sessions.json { "email": "[email protected]", "password": "somepassword" } | |
=> { "user_credentials": "123abc" } | |
GET /case_filters/1/cases.json?user_credentials=123abc | |
=> [ ...cases ... ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserSession < Authlogic::Session::Base | |
single_access_allowed_request_types :any | |
before_create :reset_single_access_token | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Api::V2::UserSessionsController < Api::V2::BaseController | |
# Check to ensure request came from an assistly application (mobile/api console/etc) | |
before_filter :assistly_client_application_required, :only => :create | |
def create | |
@user_session = UserSession.new(params[:user_session]) | |
if @user_session.save | |
render :json => { :success => true, | |
:user_credentials => @user_session.user.single_access_token } | |
else | |
render :json => { :success => false, :message => "Invalid Login" }, :status => :unauthorized | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment