-
Notifications
You must be signed in to change notification settings - Fork 312
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
fix(authenticator): propagate username from signUp actor to top level machine #4923
Changes from all commits
43141d3
f8329db
8a19ea2
e687ff2
efa1407
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@aws-amplify/ui": patch | ||
"@aws-amplify/ui-vue": patch | ||
--- | ||
|
||
fix(authenticator): propagate username from signUp actor to top level machine |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,15 +18,14 @@ const logger = new Logger('SetupTotp-logger'); | |
|
||
// `facade` is manually typed to `UseAuthenticator` for temporary type safety. | ||
const facade: UseAuthenticator = useAuthenticator(); | ||
const { updateForm, submitForm, toSignIn } = facade; | ||
const { error, isPending, QRFields, totpSecretCode, username } = toRefs(facade); | ||
const { updateForm, submitForm, toSignIn, totpSecretCode, username, QRFields } = | ||
facade; | ||
const { error, isPending } = toRefs(facade); | ||
|
||
const { totpIssuer = 'AWSCognito', totpUsername = username.value } = | ||
QRFields.value ?? {}; | ||
const { totpIssuer = 'AWSCognito', totpUsername = username } = QRFields ?? {}; | ||
|
||
const totpCodeURL = totpSecretCode.value | ||
? getTotpCodeURL(totpIssuer, totpUsername!, totpSecretCode.value) | ||
: null; | ||
// `totpSecretCode` is typed as `string | null` but will always be populated by the machine here | ||
const totpCodeURL = getTotpCodeURL(totpIssuer, totpUsername, totpSecretCode!); | ||
Comment on lines
-27
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Truthiness check of
|
||
|
||
const qrCode = reactive({ | ||
qrCodeImageSource: '', | ||
|
@@ -40,17 +39,14 @@ const { getCopyText, getCopiedText, getBackToSignInText, getConfirmText } = | |
const copyTextLabel = ref(getCopyText()); | ||
|
||
function copyText() { | ||
if (totpSecretCode.value) { | ||
navigator.clipboard.writeText(totpSecretCode.value); | ||
if (totpSecretCode) { | ||
navigator.clipboard.writeText(totpSecretCode); | ||
} | ||
copyTextLabel.value = getCopiedText(); | ||
} | ||
|
||
// lifecycle hooks | ||
onMounted(async () => { | ||
if (!username.value || !totpCodeURL) { | ||
return; | ||
} | ||
try { | ||
qrCode.qrCodeImageSource = await QRCode.toDataURL(totpCodeURL); | ||
} catch (error) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QRFields
,totpSecretCode
,username
are static values and do not require reactivity