-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Auth ,Hub not exported from 'aws-amplify #12631
Comments
Hi @ThabisoBlessed - thank you for opening this issue. Can you confirm which version of aws-amplify you have installed? The reason I ask is with the latest version ( |
Hie @nadetastic these are my dependencies with the latest versions how do we carry it out , "@aws-amplify/auth": "^6.0.5",
"@aws-amplify/core": "^6.0.5",
"@aws-amplify/ui-react": "^6.0.3",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@fontsource/roboto": "^4.5.8",
"@fortawesome/fontawesome-svg-core": "^6.4.2",
"@fortawesome/free-solid-svg-icons": "^6.4.2",
"@fortawesome/react-fontawesome": "^0.2.0",
"@mui/icons-material": "^5.11.0",
"@mui/material": "^5.11.7",
"@mui/x-charts": "^6.0.0-alpha.15",
"@mui/x-data-grid": "^5.17.23",
"aws-amplify": "^6.0.5",
"chart.js": "^4.2.1",
"react": "^18.2.0",
"react-chartjs-2": "^5.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.12.0",
"react-pro-sidebar": "^1.0.0",
"react-router-dom": "^6.20.0",
"react-toastify": "^9.1.3",
"recharts": "^2.9.0",
"uuid": "^9.0.1"
``` |
@nadetastic Im seeing seeing the documemtation , how do i even get currentAuntheticatedUser ,i'm a little lost |
import { signIn } from 'aws-amplify/auth';
export default function SignIn() {
const [showPassword, setShowPassword] = useState(false);
// const [signedUser, setSignedUser] = useState(false);
const handleTogglePassword = () => {
setShowPassword(!showPassword);
};
const handleSubmit = async (event) => {
event.preventDefault();
const data = new FormData(event.currentTarget);
console.log({
email: data.get('email'),
password: data.get('password'),
});
var name = data.get('email')
var password = data.get('password')
if(name=='' || password=='')
return;
console.log('Name : '+ name)
console.log('Password : '+ password)
// Call signIn with the provided email and password
await mysignIn({ username: email, password });
};
async function mysignIn({ username, password }) {
try {
const { isSignedIn, nextStep } = await signIn({ username, password });
} catch (error) {
console.log('error signing in', error);
}
} error the 6.x.x version , |
hello @ThabisoBlessed . Are you calling sing-in on the client side ? you can also console log the underlying error to get more information. e.g |
@israx my error im calling from client side . error the 6.x.x version , |
@ThabisoBlessed looking at your And only have Once you do so, delete your node_modules and reinstall your dependencies. |
Hi @ThabisoBlessed following up here - let me know if you still need assistance. |
DOnt close yet. I get error |
Hi @brianreinhold with V6 of aws-amplify, we no longer export the Auth class, but instead provide each api as an export. This is the reason that you are seeing the error message above. We have provided a migration guide here with a specific section of how Auth has changed here. For example in previous version 5, to signIn a user would look this: import { Auth } from 'aws-amplify'
Auth.signIn({
username,
password
}); But with the latest version 6 it would look like this: import { signIn } from 'aws-amplify/auth';
signIn({
username,
password
}) |
Yes I have seen that doc. And I stumbled on a lot more documentation. But the biggest problem I am having is imports, changed method names, and parameters. If I get by the imports, intellisense usually can do the rest. SO far these imports have been hard to find. Also for objects like CognitoUser, CognitoUserSession, CognitoRefreshToken and |
@brianreinhold the second link that I shared above contains a mapping of all the v5 o v6 auth methods and also points out the ones that have been deprecated. Are there specific methods that you are not finding in that link? Re sharing the second link with the mappings: As for types, v6 provides types for inputs and outputs. For example, |
Yes I am going through that piecemeal. I have lots of methods that I use with MFA and password recovery, forget, change, etc. But I also used a lot of aws-amplify objects like CognitoUser, etc. that I pointed out above. The examples use nameless objects which are different than the ones I am using and that it making it very difficult. I personally dislike nameless objects (especially when trying to follow someone else's code and I will never force someone to go through that agony with my code. If aws-amplify no longer defines objects like CognitoUser I will eventually define my own interfaces to to define those nameless objects once I figure them out. Nameless objects like this used to have Object names like CognitoUser.
This is what is making the transition so difficult - especially when I make extensive use of the methods and objects. It was a lot easier when the signIn() method returned a Promise object whose structure I could get via an import. I used lots of methods on that CognitoUser object!! |
ITs been a struggle but slowly I am getting the pieces of the transitions. I just made use of so many objects that have disappeared. I am looking at the sign in standard case and there is no expression of what the possible values are of 'nextStep'. In the confirmation case, they are shown. In the end I am only interested in the confirmation case with MFA. Does the standard sign in include MFA or is that considered confirmation by aws-amplify? |
Another issue. I get a UserAlreadyAuthenticatedException but I cannot find where I can import this class. Spent hours looking for this kind of information. Why aren't these documented? |
https://docs.amplify.aws/javascript/build-a-backend/auth/auth-migration-guide/ |
Shame on aws-amplify team having these so many breaking changes. It's super poor engineering upgrade practices. |
@israx so, now how can i get my JWT? I used to be able to do this: import { Auth } from 'aws-amplify';
const getIdToken = async (): Promise<string> => {
const session = await Auth.currentSession();
return session.getIdToken().getJwtToken();
}; |
@mgreiner79 I have not tried. I have given up moving to version 6. It is too poorly documented and too riddled with impossible errors. |
I found it. import { fetchAuthSession } from 'aws-amplify/auth'
const session = await fetchAuthSession();
const token = session.tokens?.idToken |
Gees...talk about a complete re-write of an API. I think I will hold off on 6 until its life or death! |
Before opening, please confirm:
JavaScript Framework
React, Next.js
Amplify APIs
Authentication
Amplify Categories
auth
Environment information
Describe the bug
Expected behavior
check if user is signed in or not
Reproduction steps
Just import hub
Code Snippet
// Put your code below this line.
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
The text was updated successfully, but these errors were encountered: