Skip to content
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

No SMS Message Sent to user after calling Auth.SignIn() #5137

Closed
richAtreides opened this issue Mar 18, 2020 · 20 comments
Closed

No SMS Message Sent to user after calling Auth.SignIn() #5137

richAtreides opened this issue Mar 18, 2020 · 20 comments
Labels
Auth Related to Auth components/category

Comments

@richAtreides
Copy link

Describe the bug
I am currently implementing my own UI for the authentication workflow by integrating the Auth package within aws-amplify-js with Material-UI.

I have implemented a SignIn page which works fine and returns the appropriate user. When I added an SMS MFA layer and a page to accept the code. This is all hooked up correctly as well. However it seems that the Auth.SignIn() is not sending the SMS to my mobile phone.

I am very confused as I had this working fine when using withAuthenticator, and later Authenticator components. Furthermore I have read the underlying code on github for all of the auth components and can see no special manual trigger that is being called to send the SMS and having read the payload I get back from calling Auth.Sign() it seems clear it is sending the message to my mobile phone.

To Reproduce

  1. Build an amplify app with MFA Optional
  2. Add a user with MFA enabled and ensure phone number and email are verified
  3. Manually call auth.signin()

My SignIn() Component for completeness

import React, { useState } from 'react';
import Button from '@material-ui/core/Button';
import Typography from '@material-ui/core/Typography';
import TextField from '@material-ui/core/TextField';
import Container from '@material-ui/core/Container';
import useStyles from './useStyles';
import { useTheme, Theme } from '@material-ui/core/styles';
import { Auth } from 'aws-amplify';

export default function CustomSignIn(props: { signInStatus: (stage: string) => void }): JSX.Element {
    const theme = useTheme<Theme>();
    const classes = useStyles(theme);

    const [email, setEmail] = useState<string>('');
    const [password, setPassword] = useState<string>('');

    const setEmailInput = (event: React.ChangeEvent<HTMLInputElement>): void => {
        setEmail(event.target.value);
    };

    const setPasswordInput = (event: React.ChangeEvent<HTMLInputElement>): void => {
        setPassword(event.target.value);
    };

    const signIn = (): void => {
        Auth.signIn(email, password).then((() => props.signInStatus('ConfirmSignIn')));
    };

    return (
        <Container component="main" maxWidth="xs">
            <div className={classes.login}>
                <Typography component="h1" variant="h5" align="center" color="primary">
                    Sign in
                </Typography>
                <div className={classes.muiform}>
                    <form className={classes.muiform} noValidate>
                        <TextField
                            style={{ backgroundColor: 'white' }}
                            variant="outlined"
                            margin="normal"
                            required
                            fullWidth
                            id="username"
                            name="username"
                            autoComplete="Email Address"
                            onChange={setEmailInput}
                        />
                        <TextField
                            style={{ backgroundColor: 'white' }}
                            variant="outlined"
                            margin="normal"
                            required
                            fullWidth
                            name="password"
                            type="password"
                            id="password"
                            autoComplete="current-password"
                            onChange={setPasswordInput}
                        />
                        <Button variant="contained" color="primary" className={classes.muisubmit} onClick={signIn}>
                            Sign In
                        </Button>
                        <Button variant="contained" className={classes.muisubmit}>
                            Forgot Password?
                        </Button>
                    </form>
                </div>
            </div>
        </Container>
    );
}

Expected behavior
SMS Message received by logging in user.

@richAtreides richAtreides added the to-be-reproduced Used in order for Amplify to reproduce said issue label Mar 18, 2020
@ashika01
Copy link
Contributor

@richAtreides Could you go in your console and see if SMS is enabled for the user. I have an idea on what might be going on.

Steps to check might be:

  • Go into cognito console.
  • Open the user pool you are working with.
  • Under the users and groups, click the username of the user
  • If you see Enable SMS MFA button, enable it and try your follow again for the user.

Screen Shot 2020-03-18 at 3 30 20 PM

Let me know if this works.

@ashika01 ashika01 added Auth Related to Auth components/category investigating This issue is being investigated labels Mar 18, 2020
@richAtreides
Copy link
Author

@ashika01 Hi Again! I already checked that unfortunately and it is enabled. I additionally logged the user that is returned from the Auth.signin() method. It correctly returns my user account and in the meta data you can see that SMS is enabled and that it has my mobile phone number.

@ashika01
Copy link
Contributor

Hmm.. I see you created the totp issue that we are tracking with service team as well. Do you think there maybe a relation.?

@richAtreides
Copy link
Author

@ashika01 its unlikely they are related as I am working on separate feature branches with no cross dependency. The TOTP issue is to do with the authenticator component contained in amplify-react whereas here I am interacting directly with the amplify-js API and providing my own components using material-ui.

My issue is that surely when you call the method Auth.SignIn() if SMS MFA is enabled on a user then a lambda should be trigger to send the SMS message? Or if not is there another method I need to call?

@richAtreides
Copy link
Author

richAtreides commented Mar 19, 2020

Screenshot 2020-03-19 at 08 43 26

This is the response object I get back to the console from calling Auth.signin() and logging the response.

@richAtreides
Copy link
Author

@ashika01 I think our SMS Message limit must have been hit.

@ashika01
Copy link
Contributor

@richAtreides did u find a way to test it?

@sammartinez sammartinez added pending-close-response-required and removed investigating This issue is being investigated to-be-reproduced Used in order for Amplify to reproduce said issue labels Mar 19, 2020
@richAtreides
Copy link
Author

@ashika01, I have tried again yet but I solved it by just implementing my own custom TOTP using soft tokens. It works fine, I built it using the auth API directly and integrating it with Material-UI.

@ashika01
Copy link
Contributor

@richAtreides Cool. we have a beta of new UI components out and we are working on making this follow better. If u want to give it a try we have it in preview. #3279 (comment) we are working on documentation for this right now. But we have a TOTP flow integrated in this.

@nihp
Copy link

nihp commented May 19, 2020

Verification code (SMS) not received for the user while Auth.signUp in aws-amplify-react-native.

How can I check the user received code or not and need to enable MFA for that particular user.

@KOSSOKO
Copy link

KOSSOKO commented Jun 28, 2020

@nihp did you find a solution ?

@vasujogani
Copy link

Also having same problem with signup not sending codes to certain phones

@nihp
Copy link

nihp commented Jul 17, 2020

KOSSOKO I can able to get the code while signUp. But I didn't get any solution how to track this. Did the user received the code or not? Still searching.

@cor1
Copy link

cor1 commented Jul 23, 2020

@richAtreides I had the same problem but I fixed it by requesting a dedicated long number in aws pinpoint. Amplify was getting successful responses and sns reported successes, however I couldnt get the messages some days and others I could. I am assuming this is because when you dont have a dedicated phone number to send messages from you get an aws default one that is most likely being carrier filtered (twilio has a great article on this). You can get around this by using your own dedicated numbers.

@richAtreides
Copy link
Author

@richAtreides I had the same problem but I fixed it by requesting a dedicated long number in aws pinpoint. Amplify was getting successful responses and sns reported successes, however I couldnt get the messages some days and others I could. I am assuming this is because when you dont have a dedicated phone number to send messages from you get an aws default one that is most likely being carrier filtered (twilio has a great article on this). You can get around this by using your own dedicated numbers.

@cor1 Thanks a lot for the tip. I actually ended up creating my own Auth flow using Soft Tokens to avoid the whole phone number thing all together. I posted a guide on how to do it here: https://levelup.gitconnected.com/guide-soft-token-authentication-with-aws-amplify-cognito-and-material-ui-react-with-typescript-31094f96968b.

@s10mcow
Copy link

s10mcow commented Feb 18, 2021

I just ran into this issue and it seems to be related to my ATT phone...

https://forums.aws.amazon.com/thread.jspa?threadID=236521

@mikeRChambers610
Copy link

I am having the same exact issue. Result from API call is telling me that the code is being sent SMS to my phone. But no code is ever received. It was woking before and no longer works.
​​
CODE_DELIVERY_DELIVERY_MEDIUM: "SMS"
​​
CODE_DELIVERY_DESTINATION: "+*******8242"

@reberthkss
Copy link
Contributor

Same issue. But i couldn't understand how to increase the limit in sns.

@Muzammil98
Copy link

Muzammil98 commented Jul 15, 2022

To anyone not receiving SMS from SNS, first check Delivery statistics under SNS -> Text Messaging. It shows the # of messages sent successfully or failed.

By default on sandbox mode, SNS limits upto 10 SMS per day (only verified recipient phone numbers) and fail to send more than that.
image

Either, you can add some test phone numbers in the sandbox mode or you'll probably have to exit-sandbox mode by going on SNS -> Text-Messaging. Here you should find exit-sandbox if not in production mode. Open the case for AWS Support, give in some details of your project and in 24 hrs it should be in production mode with monthly spending limit.

@github-actions
Copy link

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 amplify-help forum.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Auth Related to Auth components/category
Projects
None yet
Development

No branches or pull requests