Guest User

Untitled

a guest
Feb 15th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. var authenticity_token;
  2.  
  3. // Get a crsf token
  4. pm.sendRequest({
  5. url: 'http://localhost:3000/users/email',
  6. method: 'GET'
  7. }, function(err, res){
  8. html = cheerio(res.text());
  9. authenticity_token = html.find("input[name='authenticity_token']").attr("value");
  10. console.log(authenticity_token);
  11. pm.environment.set("xsrf-token", authenticity_token);
  12.  
  13. });
  14.  
  15. // login to the api
  16. pm.sendRequest({
  17. url: 'http://localhost:3000/users/sign_in',
  18. method: 'POST',
  19. header: 'X-CSRF-TOKEN:{{xsrf-token}}',
  20. body: {
  21. mode: 'raw',
  22. raw: JSON.stringify({user: {email: '...', password: '...' }})
  23. }
  24. }, function (err, res) {
  25. // pm.environment.set("cookie", res.json().cookie);
  26. // console.log(res);
  27.  
  28. });
  29.  
  30. 4:36:16 web.1 | Started POST "/users/sign_in" for ::1 at 2019-02-15 14:36:16 -0600
  31. 14:36:16 web.1 | Started GET "/users/email" for ::1 at 2019-02-15 14:36:16 -0600
  32. 14:36:16 web.1 | Processing by SessionsController#email as */*
  33. 14:36:16 web.1 | Processing by SessionsController#create as */*
  34. 14:36:16 web.1 | Can't verify CSRF token authenticity.
  35. 14:36:16 web.1 | Completed 401 Unauthorized in 8ms (ActiveRecord: 0.0ms)
  36. 14:36:16 web.1 |
  37. 14:36:16 web.1 |
  38. 14:36:16 web.1 | Processing by SessionsController#failure as */*
  39. 14:36:16 web.1 | Can't verify CSRF token authenticity.
  40. 14:36:16 web.1 | Rendering devise/sessions/email.html.erb within layouts/devise
  41. 14:36:16 web.1 | Rendered devise/shared/_links.html.erb (1.0ms)
  42. 14:36:16 web.1 | User Load (2.0ms) SELECT "users".* FROM "users" WHERE "users"."email" IS NULL LIMIT $1 /*controller:sessions,action:failure*/ [["LIMIT", 1]]
  43. 14:36:16 web.1 | Rendered devise/sessions/email.html.erb within layouts/devise (6.1ms)
  44. 14:36:16 web.1 | Redirected to http://localhost:3000/users/sign_in
  45. 14:36:16 web.1 | Ahoy::Visit Load (0.9ms) SELECT "ahoy_visits".* FROM "ahoy_visits" WHERE "ahoy_visits"."id" = $1 LIMIT $2 /*controller:sessions,action:failure*/ [["id", "d0551d2c-2117-4f03-8e22-39631dd21d1c"], ["LIMIT", 1]]
  46. 14:36:16 web.1 | Completed 302 Found in 17ms (ActiveRecord: 2.9ms)
  47. 14:36:16 web.1 |
  48. 14:36:16 web.1 |
  49. 14:36:16 web.1 | Processing by SessionsController#new as */*
  50. 14:36:16 web.1 | Can't verify CSRF token authenticity.
  51. 14:36:16 web.1 | Rendered devise/shared/_faq.html.erb (0.4ms)
  52. 14:36:16 web.1 | Rendering devise/sessions/new.html.erb within layouts/devise
  53. 14:36:16 web.1 | Rendered devise/sessions/new.html.erb within layouts/devise (0.5ms)
  54. 14:36:16 web.1 | Rendering layouts/static.html.erb
  55. 14:36:16 web.1 | Rendered devise/shared/_faq.html.erb (0.5ms)
  56. 14:36:16 web.1 | Rendering layouts/static.html.erb
  57. 14:36:16 web.1 | Rendered application/_header.html.erb (23.7ms)
  58. 14:36:16 web.1 | Rendered application/_header.html.erb (2.7ms)
  59. 14:36:16 web.1 | Rendered application/_footer.html.erb (2.4ms)
  60. 14:36:16 web.1 | Rendered application/_footer.html.erb (3.3ms)
  61. 14:36:16 web.1 | Rendered layouts/static.html.erb (237.4ms)
  62. 14:36:16 web.1 | Rendered layouts/static.html.erb (250.9ms)
Add Comment
Please, Sign In to add comment