Closed dbhagen closed 2 years ago
I played around with this a little more last night. When I console.log(SSR.Auth.user)
I got NULL
. when I called console.log(SSR.Auth.currentAuthenticatedUser())
I got the user session. When I called console.log(SSR.Auth.user)
after currentAuthenticatedUser
, it returns the user session. None of the above impacts Datastore trying to use USER_POOL
to access data that does not have API access (Owner only)
EDIT: forgot the method I tested with was actually currentAuthenticatedUser
Might be related to #9179.
Updated https://github.com/dbhagen/sample-amplify-nextjs-prj/commit/53a87a4210c5915601e43f11bd296cd0da338a91 for example of the currentAuthenticatedUser()
populating SSRuser.
And now sample TestModel code: https://github.com/dbhagen/sample-amplify-nextjs-prj/commit/657a4382dd5bdc42e1c7548b00d491261d2e1b35
Hi @dbhagen 👋 it seems that you were able to get the user session on the server.
withSSRContext
has to initialize Amplify on every request and while it populates the Credentials module based on the cookie from the request, I don't think it will automatically store a CognitoUser within the Auth module until currentAuthenticatedUser
is called so that's probably why it has to be called first, and it is convention to rely on that async request from Cognito as seen in our doc examples anyway.
Going to close this issue. If you are still in need of assistance on this issue, please reply and I'll re-open. Otherwise, if you are experiencing a different issue, please open a new one with the related info.
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server *-help
channels or Discussions for those types of questions.
Before opening, please confirm:
JavaScript Framework
Next.js
Amplify APIs
Authentication, DataStore
Amplify Categories
auth
Environment information
Describe the bug
Basic setup for an Auth project using multiple example projects. Using
create-next-app
and a basic Amplify project with basic auth enabled (checksrc/aws-exports.js
). But when run, the server-side doesn't process user sessions. Check SSRuser output onindex.js
. If you run locally, the console also shows server-side output better.Possibly related to:
Expected behavior
Expecting to see user data (ID, groups, etc).
Also potentially blocking DataSync from making calls. I'm seeing on another project:
Reproduction steps
Also can use:
Code Snippet
Log output
aws-exports.js
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response