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.
Related
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.
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.
I am using the Google Sign-In JavaScript client and also referencing the Example App
The example app (app.js) tells me that login_hint is a valid option for the signIn method:
// If the user is not signed in with expected account, let sign in.
return auth2.signIn({
// Set `login_hint` to specify an intended user account,
// otherwise user selection dialog will popup.
login_hint: id || ''
});
But the reference manual does not say it does anything there but is only effective with the authorize() method. Elsewhere on the Web I see examples of it being also used with the init() method.
Can someone please clarify any/all places where the login_hint option is functionally active?
From the login_hint
Optional. If your application knows which user is trying to
authenticate, it can use this parameter to provide a hint to the
Google Authentication Server. The server uses the hint to simplify the
login flow either by prefilling the email field in the sign-in form or
by selecting the appropriate multi-login session.
Set the parameter value to an email address or sub identifier, which
is equivalent to the user's Google ID.
To set this value in PHP, call the setLoginHint function:
$client->setLoginHint('user#example.com');
Code for you:
options = new gapi.auth2.SigninOptionsBuilder();
options.setAppPackageName('com.example.app');
options.setFetchBasicProfile(True);
//options.setPrompt('select_account');
options.setLoginHint('user#example.com');
options.setScope('profile').setScope('email');
auth2.signIn(options);
I am learning to code and am attempting to build a to do web application in node using Express (I think that's the right wording).
I have a table('users') in postgresql which stores user_id,email and password.
When a user logs in to the website I want to loop through the table and ensure the email exists and it matches the password and then the user can log in and when they're logged in - their unique user_id is assigned and brings up their previous to do lists.. I would like to incorporate knex also if possible.
I am at a loss how to do this and would appreciate any tips/pointing in the right direction.
Thanks
Try something basic first
SELECT
user_id
FROM users
WHERE
email = _your_user_email
AND password = _your_user_password;
If the result you get back contains user_id or whatever you want returned, then the user exists. You can expand on this further by checking for email, and let the user know that the email exists but the password is incorrect, etc. Try the simple method first and see if this meet your need.
First of all, I would recommend you to name your id field for your users table as id.
It is best practice to name id fields as id and reference columns as <tablename>_id
(eg. table clothes.id unique identifier for iter and clothes.user_id – foreign key to table users).
Secondly, it is highly NOT recommended to store your passwords as raw data inside of the database (security reasons).
It is a common practice to keep user passwords as hashed data.
For example, take a look at bcrypt package.
To select users (there is no such thing as "loop" in terms of database, it is called "query") you need to
create a query like
select
id,
email,
<any_other_field_you_need>
from
users
where
email = 'your#email.com'
and password = 'your password hash'
In terms of knex it can be written
knex('users')
.select(['id', 'email', '<any_other_field_you_need>'])
.where('email', 'your#email.com')
.where('password', 'your password hash')
Your query params (email, password) you can get from express body.
Make sure you are using POST HTTP method to send your request and pass your data as a body.
In case you don't know express – it's an npm package.
It helps in the creation of web-services. They have a hello world guide on their
official website. Feel free to check it out. Or just simply google "express tutorial for beginner" there are a lot of great tutorials over the internet about it. It's quite popular.
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.