Created
September 8, 2021 22:10
-
-
Save josefaidt/77df7f741ddb7b4ae046d0b9309c8cc9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/pages/_app.js | |
import { Amplify, Auth } from 'aws-amplify' | |
import { | |
AmplifyAuthenticator, | |
AmplifySignUp, | |
AmplifySignIn, | |
AmplifySignOut, | |
} from '@aws-amplify/ui-react' | |
import config from '../aws-exports.js' | |
Amplify.configure(config) | |
const handleSignUp = async formData => { | |
const overrides = { | |
username: String(Date.now()), | |
} | |
const data = await Auth.signUp(Object.assign(formData, overrides)) | |
return data | |
} | |
export default function App({ Component, pageProps }) { | |
return ( | |
<AmplifyAuthenticator usernameAlias="email"> | |
<AmplifySignUp | |
slot="sign-up" | |
usernameAlias="email" | |
formFields={[ | |
{ | |
type: 'email', | |
label: 'email', | |
placeholder: '[email protected]', | |
inputProps: { required: true, autocomplete: 'username' }, | |
}, | |
{ | |
type: 'password', | |
label: 'password', | |
placeholder: 'hunter2', | |
inputProps: { required: true, autocomplete: 'new-password' }, | |
}, | |
]} | |
handleSignUp={handleSignUp} | |
/> | |
<AmplifySignIn | |
slot="sign-in" | |
usernameAlias="email" | |
formFields={[ | |
{ | |
type: 'email', | |
label: 'email', | |
placeholder: '[email protected]', | |
inputProps: { required: true, autocomplete: 'username' }, | |
}, | |
{ | |
type: 'password', | |
label: 'password', | |
placeholder: 'password', | |
inputProps: { required: true, autocomplete: 'new-password' }, | |
}, | |
]} | |
/> | |
<AmplifySignOut /> | |
<Component {...pageProps} /> | |
</AmplifyAuthenticator> | |
) | |
} |
Author
josefaidt
commented
Sep 9, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment