Giter Club home page Giter Club logo

Comments (10)

rawinkler avatar rawinkler commented on July 28, 2024 13

After some googling (quite hidden, so that unfortunately I lost the link and I can't cite) I went with the following solution of changing the 'original hack' of

this.cdRef.detectChanges()

in the onAuthUIStateChange handling, as stated in the official Angular Amplify docu, towards

this.ngZone.run(() => this.cdRef.detectChanges());

after adding the ngZone reference to the constructor.

Of course, this seems to be an even stronger hack than the original one, but at least it works now.

from amplify-ui.

wlee221 avatar wlee221 commented on July 28, 2024 2

Hello, sorry about the silence here -- we have released @aws-amplify/[email protected] which adheres to Angular best principles than the previous web component version. Please see

to get started, thanks 🙏

from amplify-ui.

jdavidhermoso avatar jdavidhermoso commented on July 28, 2024 1

Same for me, unfortunately. Is there some update or does anyone have a smart workaround idea?
What I finally did is to log-in, log-out, etc. manually and create my own components.

from amplify-ui.

alexvdvalk avatar alexvdvalk commented on July 28, 2024

Also seeing the same issue. Thanks for raising.

from amplify-ui.

jdavidhermoso avatar jdavidhermoso commented on July 28, 2024

Is there some update about this issue?

from amplify-ui.

rawinkler avatar rawinkler commented on July 28, 2024

Same for me, unfortunately. Is there some update or does anyone have a smart workaround idea?

from amplify-ui.

reg19b avatar reg19b commented on July 28, 2024

I had to deal with my own components too!

from amplify-ui.

SomnathS09 avatar SomnathS09 commented on July 28, 2024

@rawinkler Thank you so much , I don't know about ngZone or detectChanges but this worked.
Actually
I wanted to call my server api (Lets say getMyUsername) that resolves cognito id to username in my server's database
Then load the component which we wrap like

<amplify-authenticator *ngIf="authState !== 'signedin'"></amplify-authenticator>

<div *ngIf="authState === 'signedin' && user" class="App">
    <amplify-sign-out></amplify-sign-out>
    <!-- This is where you application template code goes -->
<my-next-component><my-next-component>  
</div>

Because I am not using auth guard, I was wondering how to wait for getMyUsername to finish and pass the username to my-next-component, I have this in app.component.html

so, in onAuthUIStateChange, I needed some wait to finish for getMyUsername before moving to my-next-component

To solve this, I subscribed to getMyUsername and set load:boolean = true;
and added load in following div in app.html

<amplify-authenticator *ngIf="authState !== 'signedin'"></amplify-authenticator>

<div *ngIf="load && authState === 'signedin' && user" class="App">
    <amplify-sign-out></amplify-sign-out>
    <!-- This is where you application template code goes -->
<my-next-component><my-next-component>  
</div>

Let me know how can we achieve something that I wanted to do in better way, because I think this is not the way, Right?

How can I get the control when signin or signup of ui component is clicked and what happens after that , where is code of it and how to customize it for my use-case.

Thanks community , you're always there. UNITY IS PERFECT

from amplify-ui.

BatteryAcid avatar BatteryAcid commented on July 28, 2024

I was never able to even get the ngOnDestroy() to be hit once the ngIf kicked in - so I just ended up using the Hub to listen for auth events: https://docs.amplify.aws/guides/authentication/listening-for-auth-events/q/platform/js/

import { Hub } from 'aws-amplify';

Hub.listen('auth', (data) => {
  switch (data.payload.event) {
    case 'signIn':
        console.log('user signed in');
        break;
    case 'signUp':
        console.log('user signed up');
        break;
    case 'signOut':
        console.log('user signed out');
        break;
    case 'signIn_failure':
        console.log('user sign in failed');
        break;
    case 'configured':
        console.log('the Auth module is configured');
  }
});

from amplify-ui.

Rajan-Gupta1 avatar Rajan-Gupta1 commented on July 28, 2024

@wlee221 I have spent time looking at the documentation at the link provided above for angular but unable to determine how I can call a method after a successful login.
Is there a sample app of angular which is available?

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.