如何为站点 headers 配置 amplify-authenticator 登录?

How to configure amplify-authenticator signIn for site headers?

我正在为 Angular here.

使用最新的 Amplify Authenticator

按照建议,我可以使用以下代码,这样我就可以拥有一个 sign-in 页面:

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

<div *ngIf="authState === 'signedin' && user" class="App">
    <amplify-sign-out></amplify-sign-out>
    <div>Hello, {{user.username}}</div>
    <!-- This is where you application template code goes -->  
</div>

一切正常。但是,当我在 Angular 中的 header 组件中使用它时遇到问题,因为我想在 header 中设置退出按钮。每当我输入有效的 <amplify-sign-out> 但一旦我注销,登录表单就会显示在 header 中(因为 <amplify-authenticator> 部分)。

您有什么解决方法可以建议吗?

我刚刚发现要为 Amplify 实施身份验证,有两种选择——UI 库或通过 Auth class 使用身份验证方法。

我在上面的问题中一直在使用 UI 库。 Auth class 可用于更多定制应用。