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

Custom session storage middleware documentation incorrect #1231

Closed
Szeraax opened this issue Jan 9, 2024 · 0 comments · Fixed by #1232
Closed

Custom session storage middleware documentation incorrect #1231

Szeraax opened this issue Jan 9, 2024 · 0 comments · Fixed by #1232

Comments

@Szeraax
Copy link
Contributor

Szeraax commented Jan 9, 2024

Describe the Change

The tutorial on Sessions gives a suggestion on how to write a custom storage provider with Redis. It suggests that you convert from JSON to Hashtable (ConvertFrom-Json -AsHashTable). However, it doesn't call out that the Data.Auth.User object actually NEEDS to be an object in order for the user session to work properly (such as displaying the username in the header of the site).

https://github.com/Badgerati/Pode/blob/develop/docs/Tutorials/Middleware/Types/Sessions.md#storage

I wrote my own in-memory provider and it worked fine. But when trying to roundtrip to JSON in Azure Tables or even in my in-memory provider (both with -AsHashTable), the session would work but the username wouldn't appear in the app header.

From this code, I determined the cause:

try {
        $s.Data.Data.GetType() | Out-Default
        $s.Data.Data.Auth.GetType() | Out-Default
        $s.Data.Data.Auth.User.GetType() | Out-Default
    }
    catch {}

image

Additional Context

I would suggest editing the example and adding a paragraph about how the User property in the hashtable MUST be a PSObject. I will go file a PR as a first pass.

Workaround

I am able to get my project working via: $s.Data.Data.Auth.User = [PSCustomObject]$s.Data.Data.Auth.User

@Badgerati Badgerati added this to the 2.10.0 milestone Apr 11, 2024
@Badgerati Badgerati linked a pull request Apr 11, 2024 that will close this issue
@github-project-automation github-project-automation bot moved this from Backlog to Done in 🚀 Pode Roadmap Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants