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

Added additional error translation text for SMS MFA #1207

Merged
merged 2 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/many-bags-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@aws-amplify/ui-react': patch
---

Added translations for errors for confirm sign in
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import { Component } from '@angular/core';
import { Component, OnInit } from '@angular/core';

import { Amplify } from 'aws-amplify';
import { Amplify, I18n } from 'aws-amplify';

import { translations } from '@aws-amplify/ui';

import awsExports from './aws-exports';

@Component({
selector: 'sign-in-sms-mfa',
templateUrl: 'sign-in-sms-mfa.component.html',
})
export class SignInSMSMFAComponent {
export class SignInSMSMFAComponent implements OnInit {
constructor() {
Amplify.configure(awsExports);
}

ngOnInit() {
I18n.putVocabularies(translations);
I18n.setLanguage('en');
I18n.putVocabulariesForLanguage('en', {
'Invalid code or auth state for the user.': 'translated text',
});
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import { Amplify } from 'aws-amplify';
import { Amplify, I18n } from 'aws-amplify';

import { Authenticator } from '@aws-amplify/ui-react';
import '@aws-amplify/ui-react/styles.css';

import { translations } from '@aws-amplify/ui';
import awsExports from './aws-exports';
Amplify.configure(awsExports);

I18n.putVocabularies(translations);
I18n.setLanguage('en');

I18n.putVocabulariesForLanguage('en', {
'Invalid code or auth state for the user.': 'translated text',
});

export default function AuthenticatorWithSmsMfa() {
return (
<Authenticator>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
<script setup lang="ts">
import Amplify from 'aws-amplify';
import Amplify, { I18n } from 'aws-amplify';
import '@aws-amplify/ui-vue/styles.css';
import { Authenticator } from '@aws-amplify/ui-vue';
import { translations } from '@aws-amplify/ui';
import aws_exports from './aws-exports';

Amplify.configure(aws_exports);

I18n.putVocabularies(translations);
I18n.setLanguage('en');

I18n.putVocabulariesForLanguage('en', {
'Invalid code or auth state for the user.': 'translated text',
});
</script>

<template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Feature: Sign In with SMS MFA
And I click the "Sign in" button
Then I will be redirected to the confirm sms mfa page


@angular @react @vue
Scenario: Redirect to sign in page
When I select my country code with status "CONFIRMED"
Expand All @@ -25,14 +26,14 @@ Feature: Sign In with SMS MFA
Then I see "Sign in"

@angular @react @vue
Scenario: Incorrect SMS code
Scenario: Incorrect SMS code with translated text
When I select my country code with status "CONFIRMED"
And I type my "phone number" with status "CONFIRMED"
And I type my password
And I click the "Sign in" button
And I type an invalid SMS code
And I click the "Confirm" button
Then I see "Invalid code or auth state for the user."
Then I see "translated text"

@angular @react @vue
Scenario: Sign in with unknown credentials
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ export const ConfirmSignIn = (): JSX.Element => {
break;
default:
throw new Error(
`Unexpected challengeName encountered in ConfirmSignIn: ${challengeName}`
`${translate(
'Unexpected challengeName encountered in ConfirmSignIn:'
)} ${challengeName}`
);
}
const handleChange = (event: React.FormEvent<HTMLFormElement>) => {
Expand Down Expand Up @@ -67,7 +69,7 @@ export const ConfirmSignIn = (): JSX.Element => {
<Heading level={3}>{headerText}</Heading>

<Flex direction="column">
<ConfirmationCodeInput errorText={error} />
<ConfirmationCodeInput errorText={translate(error)} />
</Flex>

<ConfirmSignInFooter />
Expand Down