AWS cognito username exists exception - javascript

I'm using Amazon Cognito to sign-up for an application. While doing this, I'm getting "UsernameExistsException: user name already exists". I have given all forms of username, still getting this error. How to check whether the username is already registered or not? Also, please tell how to rectify this exception

You can check to see if a user already exists in Cognito by logging into the AWS Console, or by visiting this url.
If the user does not already exist, check to ensure that you are not attempting to register a user with an aliased attribute. For example, if you have set an alias for phone_number, all registered phone numbers must also be unique.
If you are still having trouble with this problem, can you please post any supporting code to help me answer it better.

Related

Check whether the user has a valid credentials Jira rest API

I am using jira-client npm module to make API calls on my jira instance, I want to check that if the user has a valid credentials before doing anything else, depending on that I would either:
Tell the user that they don't have a valid username or token.
or Let the user use the project functionalities
is that possible? I am able to make calls and with invalid credentials I will got response with a special message, but I want to know if there is a specific call for checking username and token.
Using normal fetch we can use
https://myJiraInstance/rest/auth/1/session
but for jira-client module it seems there is no way, however we can use findproject method in this way we can make sure that the user has a valid credentials as well as have access to the project itself.
If there any other solution I would be happy to have it.

Search for user by Username in AWS Cognito

Is it possible to find a user by searching with a Username in AWS Lambda? The GetUserCommand does not seem to accept a Username as a parameter. The input shape does not include a Username parameter. Am I misunderstanding?
GetUserCommand documentation.
The command you are referring to only needs an access token. Since the access token belongs to your user it will return information about her/him. You don't really need to provide a username. Would be kind of redundant.
If you want to get information about a user as an admin (so not as a user that is currently signed in), then you need another method: AdminGetUserCommand. There you can specify which username you want using AdminGetUserCommandInput.

change email username on cognito aws

Users are login using Cognito to our app and the email is used as username.
The PM asked for the option to change username but, seems like AWS doesn't give that option.
const res = await cognito.adminUpdateUserAttributes({UserPoolId:userPoolId, Username:body.uuid, UserAttributes:[{Name:'email', Value:body.newEmail}]}).promise();
return createResponse(200, 'ok');
Now it returns empty response without errors but I don't see the user email changed, I also tried to add email_verified:true but nothing happened. Anyone knows a workaround?
1.Only option for you to do here is either migrate to a new pool while migrating change the username.
2.If you want to change the login username continuously you can use username or preferred username as alias for the cognito. There is option while configuring and cannot be changed after pool is created.

Firebase limit user write access

i setup rules to limit user access like this:
.write": "auth != null && !root.child('blockedUsers').hasChild(auth.uid)",
The problem is, i dont know how to use it on the client side. I am assuming this is duplicate question, but i cant find anything on actual usage of the limited user access.
When user tries to create comment for example, i get an error that permission is denied. Thats desired result, problem is how do i check for the user write permission on the client ?
I was hoping for something like user.canWrite or something along those lines. All i am doing right now is just check if user was authenticated, which he was and there is no mention of read/write access rules in the user object as far as i can tell.
if (this.props.user) {
firebase.database().ref(`comments/${key}/rating`)
.transaction(
(value) => (value += rateValue)
)}
Thanks for any help.
By writing you rule you are setting an authorization to authenticated users to write to the specific node of your database.
Therefore, in the client, you only need to insure that your user is authenticated. This should be done through Firebase Authentication. See the doc for the web here: https://firebase.google.com/docs/auth/web/start
In case the user cannot write to this specific node (either because he/she is not authenticated or because his/her uid is listed under the blockedUsers) he/she will receive an error in the front-end.
Update following our comments below:
If you want to be able "to modify the client UI based on the user's role or access level" you should use another mechanism for setting up the authorization: Custom Claims. See the doc here: https://firebase.google.com/docs/auth/admin/custom-claims.
In this case, in the security rule, you would not check if there is a record under the 'blockedUsers' node but you would check the Claims attached to the token, as explained in the documentation.

Username cannot be of email format, since user pool is configured for email

When I try sign up an user in AWS Cognito this error is returned in response.:
But, in my config the email field is an alias.:
How can I fix this?
By that error message, it looks like it's failing because you have email as an alias but have also set given it as your username. I think to get around this, you could either use some temporary, throw away username at first or un-check it as an alias and just use it as both username and an attribute. The former gives you more flexibility to updating it, but that's ultimately up to your application's needs.

Categories

Resources