Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to implement is use express-session #21

Open
Feruz00 opened this issue Jun 7, 2023 · 0 comments
Open

how to implement is use express-session #21

Feruz00 opened this issue Jun 7, 2023 · 0 comments

Comments

@Feruz00
Copy link

Feruz00 commented Jun 7, 2023

Dear Sir. How to implement testing user authention with send create cookie. I use express-session and I do this:

test.only("When signed in , shows logout button", async ()=>{
    const cookieSignature = require('cookie-signature');
    const { Buffer } = require('safe-buffer');
    const keys = require('../config/keys');

    const id = "64732491418fea82e9d214e1";

    const sessionObject = {
        passport: {
          user: id
        }
      };
    const cookie = require('cookie')

    const sessionString = JSON.stringify(sessionObject);

    const signature = "s:"+cookieSignature.sign(Buffer.from(sessionString).toString('base64'), keys.cookieKey);

    
    var data = cookie.serialize('connect.sid', signature);

   
    await page.setCookie({name: "connect.sid", value: data.split('=')[1]});

    await page.goto("http://localhost:3000");
    
})

Problem here creating sessionId and I cannot find any tutorial about this. Please help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant