【发布时间】:2020-04-03 05:06:41
【问题描述】:
更改密码.ts
changePw(email: HTMLInputElement, contactNo: HTMLInputElement, username: HTMLInputElement, password: HTMLInputElement) {
console.log("changepasswordhere");
const user = {
password: password.value,
attributes: {
email: email.value
}
}
console.log(user)
Auth.currentAuthenticatedUser()
.then(user => {
console.log("data " + user);
this.toVerifyEmail = true;
})
.catch(err => console.log(err));
// console.log(user)
}
更改密码.html
<label for="inputEmail" class="sr-only">Username</label>
<!-- <input type="text" required (keypress)="numberOnly($event)" id="confirmationcode" class="form-control" placeholder="Confirmation Code" [(ngModel)]="confirmationcode" name="confirmationform" required autofocus> -->
<input
type="number"
class="form-control"
id="exampleInputverifycode1"
aria-describedby="verifyCodeHelp"
placeholder="Enter the code"
#verifycode
/>
<input
type="password"
id="inputPassword"
class="form-control"
placeholder="New Password"
[(ngModel)]="newpassword"
name="loginform"
required
autofocus
/>
<input
type="password"
id="inputPassword"
class="form-control"
placeholder="Confirm New Password"
[(ngModel)]="confirmpassword"
name="loginform"
required
autofocus
/>
<div class="alert alert-danger" *ngIf="message" role="alert">
{{message}}
</div>
<button
class="btn btn-lg btn-primary btn-block"
(click)="changePw(email,password,username,contactNo)"
>
Submit
</button>
在忘记密码中,输入用户名,cognito会检查名称是否存在,然后发送OTP。之后更改密码用户必须输入 OTP 来验证、新密码并确认新密码。由于我是 aws-amplify 的新手,请任何人都可以在这里给我建议。
【问题讨论】:
标签: angular aws-amplify