Closed Arnav7501 closed 1 year ago
Hi @Arnav7501 How have you verified that it's only a problem with your system?
Also do you have any custom config passed to Amplify.configure
in your app or do you just pass it the contents of aws-exports
?
Thanks for the reply, The reason I'm confused is that on other applications where i ran the exact same authentication system the user has stayed signed in, but on this particular program the user gets logged out, leading me to believe its specific to my program for some reason. In Amplify.configure, i just pass the contents of aws-exports
Interesting, were the other applications also React Native?
Did you import the entire amplify project with amplify pull --appId YOUR_APP_ID --envName YOUR_ENV_NAME
or create a new amplify project via amplify init
and then import the auth resources via amplify import auth
?
I created a new project via amplify init and used the same authentication, username and password. In both, I just use Auth.signIn to log in and it works, but on refreshing if i log Auth.currentAuthenticatedUser its logged out for god knows why
@Arnav7501 what device are you testing this on? Or is it showing up on both iOS and android?
Just copying your comment from discord to consolidate and be clear:
You are running the following:
const authuser = await Auth.currentAuthenticatedUser({bypassCache :true})
setUser(authuser)
console.log("auth",authuser)
And getting the error the user is not authenticated
Are you running these commands within an async function? I tried this on an iOS emulator and have not been able to reproduce so far
problem is on both ios and android for the program, i'll link a screenrecording of the situation
https://drive.google.com/file/d/1RjffJHRNm8HcNOZWcyJwbBcrSGaSVL3c/view?usp=sharing
If the user is authenticated, It then moves directly into the app, otherwise it stays at the signin screen, in the recording you can see once i refresh it automatically signs out the user.
Interesting, that shouldn't be happening. I'm able to close my app completely after logging in and stay signed in.
We have a known issue with duplicate Amplify instances being created if versions are mismatched, so can you follow the instructions here and let me know what your output is for that? Sometimes the multiple instances causes a user to be logged in on one but logged out on the other and cause errors like you are seeing.
Another side note that I don't think would be effecting your app but I want to clear up, I don't think you should need the package aws-amplify-react-native
as this is just for UI. There is a dev preview out for new React Native UI components and that package is on its way to deprecation. We have been trying to clean up the docs and remove the call to install that package, do you remember where you saw that?
i think i'm going to have to throw in the towel,, i upgraded amplify to the latest version through the yarn command, but it destroyed my project, Now i get this error, ERROR [ERROR] 41:10.991 DataStore - Models were generated with an unsupported version of codegen. Codegen artifacts are from an unknown version, whereas ^3.2.0 is required. Update to the latest CLI and run 'amplify codegen models'. ERROR Error: Models were generated with an unsupported version of codegen. Codegen artifacts are from an unknown version, whereas ^3.2.0 is required. Update to the latest CLI and run 'amplify codegen models'.
running amplify codegen models does not fix the problem, and it simply won't go away.
Thanks for all your time, if you have a solution to the above error i would really appreciate it, but its fine either way
Don't give up yet, if it is a problem with our library we can figure it out. I am going to reach out on discord and try to help you through this
Related to the error with the project, you should be able to remove your node_modules
folder and revert back to a previous version and run yarn
again to go back to where you were before.
For that specific DataStore error, there were changes released in v5.0.0 related to codegen's error messages. And related documentation for upgrading to v5+ if you would like to keep the latest version
@Arnav7501 you might find this stackoverflow thread helpful.
From what I read it seems to be either out of date or mismatched versions from the CLI, there are a few suggestions in the comments on how to resolve the issue
Hi 👋 Closing this as we have not heard back from you. If you are still experiencing this issue and are in need of assistance, please feel free to comment and provide us with any information previously requested by our team members so we can re-open this issue and be better able to assist you.
Thank you!
yeah i just gave up, the incident is so isolated its not worth pursuing
I'm sorry to hear that, especially knowing you are one of our discord family. We hope to be able to help better next time
no problem, you've been more helpful than 99% of people I've came across
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
Authentication
Amplify Categories
auth
Environment information
Describe the bug
User gets signed in succesfully, but on refreshing page or closing app the user gets signed out. If I run log authuser = await Auth.currentAuthenticatedUser({bypassCache :true}), i get an error that the user is not authenticated. Running on expo react native.
Expected behavior
Was expecting the user to stay signed in, and not get signed out on closing the app or refreshing
Reproduction steps
Unsure how to reproduce, seems to only be an error with my system.
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