Skip to content
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

How to create custom UIs #431

Closed
nnurmano opened this issue Mar 11, 2018 · 8 comments
Closed

How to create custom UIs #431

nnurmano opened this issue Mar 11, 2018 · 8 comments
Labels
Auth Related to Auth components/category

Comments

@nnurmano
Copy link

This is a clarification on approach. I have an existing ReactJS based project, which has custom UIs, which in turn leverage aws-cognito js libraries. Now I would like to use aws-amplify library and need to clarify how to approach the migration.
The documentation here suggests to extending the existing aws-amplify UIs
(Option#1) https://github.com/aws/aws-amplify#3-override-default-authentication-screens,
the sample provided here
(Option#2) https://github.com/awslabs/aws-mobile-react-sample, uses custom UIs. I would like to understand what is the preferred way of building custom UIs, could I still use Option#1 and achieve a completely different UIs? Or this approach has some limitations?

@nidsharm nidsharm added help wanted Auth Related to Auth components/category labels Mar 12, 2018
@richardzcode
Copy link
Contributor

Hi @nomadus Yes Option #1 is recommended way. Here is another example: https://aws.github.io/aws-amplify/media/authentication_guide.html#5-write-your-own-auth-ui

Thanks,
Richard

@nnurmano
Copy link
Author

The example you referred does not clarify on how to use Option#1. Namely, how to call AUTH methods when I have custom buttons etc. I shall come back when there is a good example, I am sticking to Option #2, compared to old Cognito approach amplify reduces quantity of code, fo sure. So this is great!

@richardzcode
Copy link
Contributor

@nomadus maybe this link helps: https://github.com/richardzcode/Journal-AWS-Amplify-Tutorial/tree/master/step-03#2-turn-loginform-into-authpiece

For example this is how to make call to sign in:

    Auth.signIn(username, password)
        .then(user => console.log('sign in success', user))
        .catch(err => console.log('sign in error', err));

@nnurmano
Copy link
Author

Hi @richardzcode ,
Thanks for the link, It helps a lot. I guess this issue could be closed now. Before closing the issue, I would like to ask another question. I shall need to know if the user is logged in or not. I believe this info is stored in authState. To access to this info, could I extend AuthPiece component in my custom Header component and then be able to access to authState object?

@powerful23
Copy link
Contributor

@nomadus I think you can access it through this.props.authState if you component is the children of Authenticator

@mlabieniec
Copy link
Contributor

@nomadus please feel free to re-open this if you think there is anything we should add for this.

@francisngo
Copy link

It looks like the link in OP is not anchored to the desired instructions anymore. I am running into an issue where I am trying to create my own custom UI and need to retrieve the response code but it looks like I can only retrieve it from Amplify's UI. Please provide any sample code, if any. Thanks!

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Auth Related to Auth components/category
Projects
None yet
Development

No branches or pull requests

6 participants