question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Customize AWS Amplify Authentication UI for React

See original GitHub issue

** Which Category is your question related to? ** Auth

** What AWS Services are you utilizing? ** Cognito

** Provide additional details e.g. code snippets ** I’m trying to create a customized UI for all the pages related to the authentication on a React app. I need a big form with various fields to be inserted when the user is signing up.

I was following this tutorial (https://github.com/richardzcode/Journal-AWS-Amplify-Tutorial) until a realize the versions for aws-amplify and aws-amplify-react were different.

I tried to read the documentation about it but is too superficial, I can’t get it, really. https://aws-amplify.github.io/amplify-js/media/authentication_guide#create-your-own-ui

I tried to look up directly in the aws-amplify-react source code and reproduce the same pattern that I found there, no success.

Here my Auth component:

import { Authenticator } from 'aws-amplify-react'

  import {
    LoginForm,
    RegisterForm,
    ConfirmRegisterForm,
    VerifyContactForm,
    ForgotPasswordForm
  } from '../components'

  export default class Login extends Component {
    render () {
      return (
        <Authenticator hideDefault>
          <LoginForm />
          <RegisterForm />
          <ConfirmRegisterForm />
          <VerifyContactForm />
          <ForgotPasswordForm />
        </Authenticator>
      )
    }
  }

And here my LoginForm:

    import React from 'react'
    import { Button, Form, Grid, Header, Image, Message, Segment } from 'semantic-ui-react'
    import Auth from '@aws-amplify/auth'
    import { ConsoleLogger as Logger } from '@aws-amplify/core'
    import { AuthPiece } from 'aws-amplify-react'

    const logger = new Logger('LoginForm')

    class LoginForm extends AuthPiece {
      constructor (props) {
        super(props)
        this.signIn = this.signIn.bind(this)
        this._validAuthStates = ['signIn', 'signedOut', 'signedUp']
        this.state = {}
        console.log('this.props->', JSON.stringify(this.props))
      }

      signIn () {
        const { username, password } = this.inputs
        logger.debug(`username: ${username}`)

        Auth.signIn(username, password)
        .then(user => this.changeState('signedIn', user))
        .catch(err => this.error(err))
      }

      showComponent (theme) {        
        const { hide = [] } = this.props

       if (hide && hide.includes(LoginForm)) {
        return null
       }

       return (
         {/* My Login Form */}
       )
    }
  }
  export default LoginForm

When I go to the login form the authState is always as loading. I can’t make them work properly because of this.

Any help is welcome.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
sophieevnexcommented, Dec 4, 2018

I found this tutorial incredibly useful, it shows you how to customise your sign in component by extending the aws-amplify SignIn component: https://dev.to/kylegalbraith/how-to-easily-customize-the-aws-amplify-authentication-ui-42pl

2reactions
ymaghzazcommented, Oct 21, 2018

I created a lib that help you customise amplify authentication UI, please check https://github.com/ysfmag/aws-amplify-react-custom-ui

Read more comments on GitHub >

github_iconTop Results From Across the Web

Customization | Amplify UI for React
Headers & Footers. The Authenticator has several "slots" that you can customize to add messaging & functionality to meet your app's needs.
Read more >
Amplify UI's new Authenticator component makes it easy to ...
Amplify UI's new Authenticator component makes it easy to add customizable login pages to your React, Angular, or Vue app.
Read more >
How to setup customize Amplify Authentication UI using Hooks?
How can we make own custom auth UI? Make changes in App.js part — import React from 'react'; import Amplify from "aws-amplify";
Read more >
using @aws-amplify/ui-react how to fully customize the Auth ...
Fully customizing the Auth flows by providing your own "slot"(not using AmplifyUIComponents at all; only using AmplifyAuthenticator and your ...
Read more >
Step 03 - Customize Authentication UI | Journal-AWS-Amplify ...
Step 03 - Customize Authentication UI · 1. Replace Sign Out. Start from the easiest, <SignOut> button. · 2. Replace Sign In. Let's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found