Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var authenticity_token;
- // Get a crsf token
- pm.sendRequest({
- url: 'http://localhost:3000/users/email',
- method: 'GET'
- }, function(err, res){
- html = cheerio(res.text());
- authenticity_token = html.find("input[name='authenticity_token']").attr("value");
- console.log(authenticity_token);
- pm.environment.set("xsrf-token", authenticity_token);
- });
- // login to the api
- pm.sendRequest({
- url: 'http://localhost:3000/users/sign_in',
- method: 'POST',
- header: 'X-CSRF-TOKEN:{{xsrf-token}}',
- body: {
- mode: 'raw',
- raw: JSON.stringify({user: {email: '...', password: '...' }})
- }
- }, function (err, res) {
- // pm.environment.set("cookie", res.json().cookie);
- // console.log(res);
- });
- 4:36:16 web.1 | Started POST "/users/sign_in" for ::1 at 2019-02-15 14:36:16 -0600
- 14:36:16 web.1 | Started GET "/users/email" for ::1 at 2019-02-15 14:36:16 -0600
- 14:36:16 web.1 | Processing by SessionsController#email as */*
- 14:36:16 web.1 | Processing by SessionsController#create as */*
- 14:36:16 web.1 | Can't verify CSRF token authenticity.
- 14:36:16 web.1 | Completed 401 Unauthorized in 8ms (ActiveRecord: 0.0ms)
- 14:36:16 web.1 |
- 14:36:16 web.1 |
- 14:36:16 web.1 | Processing by SessionsController#failure as */*
- 14:36:16 web.1 | Can't verify CSRF token authenticity.
- 14:36:16 web.1 | Rendering devise/sessions/email.html.erb within layouts/devise
- 14:36:16 web.1 | Rendered devise/shared/_links.html.erb (1.0ms)
- 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]]
- 14:36:16 web.1 | Rendered devise/sessions/email.html.erb within layouts/devise (6.1ms)
- 14:36:16 web.1 | Redirected to http://localhost:3000/users/sign_in
- 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]]
- 14:36:16 web.1 | Completed 302 Found in 17ms (ActiveRecord: 2.9ms)
- 14:36:16 web.1 |
- 14:36:16 web.1 |
- 14:36:16 web.1 | Processing by SessionsController#new as */*
- 14:36:16 web.1 | Can't verify CSRF token authenticity.
- 14:36:16 web.1 | Rendered devise/shared/_faq.html.erb (0.4ms)
- 14:36:16 web.1 | Rendering devise/sessions/new.html.erb within layouts/devise
- 14:36:16 web.1 | Rendered devise/sessions/new.html.erb within layouts/devise (0.5ms)
- 14:36:16 web.1 | Rendering layouts/static.html.erb
- 14:36:16 web.1 | Rendered devise/shared/_faq.html.erb (0.5ms)
- 14:36:16 web.1 | Rendering layouts/static.html.erb
- 14:36:16 web.1 | Rendered application/_header.html.erb (23.7ms)
- 14:36:16 web.1 | Rendered application/_header.html.erb (2.7ms)
- 14:36:16 web.1 | Rendered application/_footer.html.erb (2.4ms)
- 14:36:16 web.1 | Rendered application/_footer.html.erb (3.3ms)
- 14:36:16 web.1 | Rendered layouts/static.html.erb (237.4ms)
- 14:36:16 web.1 | Rendered layouts/static.html.erb (250.9ms)
Add Comment
Please, Sign In to add comment