Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d ' {"user": {"email":"EgorkZe@gmail.com","password":"1234"}}' http://127.0.0.1:3000/users/sign_in
  2.  
  3. session = 654a8f9be39839e0eac5b06c7224d671;
  4. success = 1;
  5. user = {
  6. "authentication_token" = "<null>";
  7. "created_at" = "2014-04-10T08:54:28.813Z";
  8. email = "egorkze@gmail.com";
  9. id = 1;
  10. "server_id" = "<null>";
  11. "updated_at" = "2014-04-11T07:27:23.580Z";
  12. };
  13.  
  14. class SessionsController < Devise::SessionsController
  15. skip_before_filter :verify_authenticity_token, only: [:show, :create, :edit, :update, :destroy]
  16.  
  17. def create
  18.  
  19. resource = warden.authenticate!(:scope => resource_name, :recall => "sessions#failure")
  20. sign_in(resource_name, resource)
  21.  
  22. respond_to do | format |
  23. format.json { render :json => { :success => true, :user => resource ,:session => session['session_id']}, :status => 200 }
  24. end
  25.  
  26. end
  27.  
  28. def failure
  29. respond_to do | format |
  30. format.json { render :status => 401, :json => {:success => false, :errors => ["Login failed."]} }
  31. end
  32.  
  33. end
  34. end
  35.  
  36. -b "session=654a8f9be39839e0eac5b06c7224d671"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement