Giter Club home page Giter Club logo

Comments (3)

ashika01 avatar ashika01 commented on July 28, 2024

@tomjannak have you tried using https://docs.amplify.aws/ui/auth/authenticator/q/framework/react#slots to achieve the use case?

from amplify-ui.

tomjannak avatar tomjannak commented on July 28, 2024

@tomjannak have you tried using https://docs.amplify.aws/ui/auth/authenticator/q/framework/react#slots to achieve the use case?

I guess the AWS Support Operator did not find this option and requested I post the feature request. From the article above, it looks like the following can work. It is better than my work around because if the user is already registered in Cognito and thus previously accepted the terms and conditions, I can default the checkbox when they land on the Sign-in equivalent of this page, versus the register/sign-up.

It is a lot more work than my workaround and there are some issues when they toggle back and forth between sign in and create account.

class App extends Component {
     constructor(props) {
          this.state = {
               ...
               UserAcceptedTermsAndConditions: false;
          }
          ...
     }
     handleRegistrationSubmit = (e) => {
          e.preventDefault();
          const { email, password } = e.target;
          if (this.state.UserAcceptedTermsAndConditions) {
               Auth.signUp(email.value, password.value, attributes: { ... }).then(response => {
                    console.log('Auth.signIn success', response);
               }).catch(error => {
                    console.log(error.response)
               });
          } else 
               alert("Please accept the terms and conditions.");
     }

     handleUserAcceptedTermsAndConditions = (e) => {
          this.setState({UserAcceptedTermsAndConditions: !this.state.UserAcceptedTermsAndConditions})
     }
 
     render() {
          return (  ...
               <form id="tncagreement" name="tncagreement">
                    <input type="checkbox" id="terms" name="terms"
                         checked={this.state.UserAcceptedTermsAndConditions}
                         ref="UserAcceptedTermsAndConditions"
                         onChange={this.handleUserAcceptedTermsAndConditions} />
                    <label for="terms">I have read and agreed to the Terms &amp; Conditions</label>
               </form>
               ...
               <AmplifyAuthenticator ...
                    <AmplifySignUp ...
                         handleSubmit={this.handleRegistrationSubmit} />
               </AmplifyAuthenticator>
          ... )
     }
}

Thanks @ashika01

from amplify-ui.

ericclemmons avatar ericclemmons commented on July 28, 2024

I added an example that address this use-case specifically via #552 here:

https://ui.docs.amplify.aws/ui/components/authenticator?platform=react#sign-up-fields

Let me know if that works for you, too! 🙏

from amplify-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.