[英]How to change background of aws amplify/cognito login/signup screen
[英]How to catch an error coming from aws cognito pre signup lambda in amplify?
我在 cognito 中使用預注冊 lambda 觸發器。 某些情況下的 pre singup lambda 會引發異常(期望行為)。 前端有如下代碼:
await Vue.prototype.$auth
.federatedSignIn({
provider: provider
}).then((d) => {
console.log('success ', d)
}).catch((e) => {
console.log('here is and error', e)
})
}
當我運行代碼時,我總是在 console.log 中看到成功消息( d 未定義),緊接着我看到以下消息: 我想知道如何才能捕獲此錯誤,我想為我放大日志,但是我如何才能捕獲它?
下面附上我的放大配置:
import Amplify, { Auth } from 'aws-amplify'
export default {
install (Vue) {
Amplify.configure({
Auth: {
region: config.auth.region,
userPoolId: config.auth.cognitoUserPoolId,
userPoolWebClientId: config.auth.cognitoClientId,
cookieStorage: {
domain: config.auth.cognitoCookieStorageDomain,
secure: config.auth.cognitoCookieStorageSecure
},
mandatorySignIn: false,
authenticationFlowType: 'USER_SRP_AUTH',
oauth: {
domain: config.auth.cognitoDomain,
scope: ['email', 'openid', 'aws.cognito.signin.user.admin'],
redirectSignIn: config.auth.cognitoSignInRedirectUrl,
redirectSignOut: config.auth.cognitoSignOutRedirectUrl,
responseType: 'code' // or 'token', note that REFRESH token will only be generated when the responseType is code
}
}
})
Vue.prototype.$auth = Auth
}
您必須在 Pre-SignupTrigger(Lambda 函數)內部處理此錯誤
假設您使用 amplify 生成此設置 - 您可以在 Lambda 函數模板中本地執行此操作,您可以在文本編輯器中對其進行編輯。 該函數的代碼應位於amplify/backend/function/<functionname>
話雖如此,為了在默認 Amplify 實施之外更靈活地使用 Amazon Cognito,您可能需要考慮導入預先存在的 Amazon Cognito 用戶池: https : //docs.amplify.aws/cli/auth/import
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.