【发布时间】:2018-12-24 09:58:28
【问题描述】:
我使用Angular forms 在我的前端进行注册和登录。这是一个经典的设置,将表单外的 POST 请求发送到后端 API。
POST 请求是从我在 form 元素上注册到 (ngSubmit)=onSubmit() 的 submit 函数发送的。
我希望密码管理器可以使用此功能:在创建用户时保存登录名/密码,在登录时自动填充,在更改密码时更新。
Dashlane 一切正常。但我最近尝试了 Lastpass,但它没有收到请求。我在this help page 上看到他们建议使用裸表单。这不是我的选择,因为我想要更好的用户体验。
我的典型形式是:
<form [formGroup]="signupFormModel" (ngSubmit)="onSubmit()"...>
<input matInput
placeholder="Email"
formControlName="email"
type="email"
name="email"
autocomplete="username"
autofill>
<input matInput
placeholder="Password"
[type]="hide_password ? 'password' : 'text'"
formControlName="password"
autocomplete="new-password"
name="new-password"
autofill>
<input matInput
placeholder="Confirm password"
[type]="hide_password ? 'password' : 'text'"
formControlName="password_confirmation"
autocomplete="new-password"
name="new-password-confirmation"
autofill>
<input mat-raised-button
type="submit"
value="Sign up">
</form>
所以你看我已经使用了autocomplete 属性,以及正确的type 和name。
我的猜测是 Lastpass 不会拦截 Submit 事件之外的请求。但这不是 Angular 表单的工作方式。 (但 Dashlane 似乎没问题)
这会引发问题,因为我不想用我的 Angular 表单测试每个密码管理器:
Angular 表单与大多数密码管理器配合使用的具体准则是什么?
【问题讨论】: