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

[Bug?]: Session "spreads" the userId string into session.data #1536

Closed
2 tasks done
ile opened this issue Jun 11, 2024 · 3 comments · Fixed by #1540
Closed
2 tasks done

[Bug?]: Session "spreads" the userId string into session.data #1536

ile opened this issue Jun 11, 2024 · 3 comments · Fixed by #1540
Labels
bug Something isn't working

Comments

@ile
Copy link

ile commented Jun 11, 2024

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

Using a solid-start app, template app which has sessions enabled, after logging in and doing console.log(session), I get this:

session {
  id: '4a4e5d74-2a7b-41b1-b2bd-936c7cbc3bd8',
  createdAt: 1718058677216,
  data: {
    '0': 'e',
    '1': '8',
    '2': 'b',
    '3': '6',
    '4': '3',
    '5': '9',
    '6': '9',
    '7': '0',
    '8': '-',
    '9': '9',
    '10': 'd',
    '11': '0',
    '12': 'c',
    '13': '-',
    '14': '4',
    '15': 'c',
    '16': 'e',
    '17': '5',
    '18': '-',
    '19': '8',
    '20': '2',
    '21': '6',
    '22': '8',
    '23': '-',
    '24': 'b',
    '25': '7',
    '26': 'c',
    '27': 'f',
    '28': 'a',
    '29': 'c',
    '30': '3',
    '31': '0',
    '32': '7',
    '33': 'e',
    '34': '7',
    '35': '3',
    userId: 'e8b63990-9d0c-4ce5-8268-b7cfac307e73'
  }
}

So it sets/assigns this userId string into the session data object by some method, which "spreads" it into the object. Probably something like Object.assign(session.data, userId);.

Expected behavior 🤔

Should not create this kind of object.

Steps to reproduce 🕹

Steps:

  1. Install a solidstart template app
  2. log in
  3. do a console.log()

Context 🔦

No response

Your environment 🌎

No response

@ile ile added the bug Something isn't working label Jun 11, 2024
@ryansolid
Copy link
Member

Honestly I'm not sure. We don't do this to my knowledge. We only use the API's provided by H3 here as pure re-export. Maybe this is H3 behavior?

@ile
Copy link
Author

ile commented Jun 11, 2024

I suspect it's H3 behavior.

@Brendonovich
Copy link
Contributor

h3 assigns the result of the update function to the session itself

image

The assignment expression is returning user.id from the function and that's ending up in Object.assign

image

Just need to wrap the update functions in braces

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants