如何在创建帐户后自动向用户发送电子邮件验证。到目前为止我有这个代码。
export class addContentComponent {
add: FormGroup;
constructor(public fb: FormBuilder) {
this.add = this.fb.group({
emailaddress: ['', Validators.required],
password: ['', Validators.required],
}); };
emailsent = '';
submitadd() {
const emailaddress = this.add.emailaddress.value;
const password = this.add.password.value;
const auth = firebase.auth();
const usertoverify = firebase.auth().currentUser;
const promise = auth.createUserWithEmailAndPassword(emailaddress, password)
}
**This is where i am confused**
usertoverify.sendEmailVerification().then(function() {
this.emailsent = 'verification email has now been sent to ' + emailaddress;
}, function(error) {
// An error happened.
});
}
我曾尝试使用此代码,但它无效 并帮忙吗?
同时这是我的HTML
<form (ngSubmit)="submitadd()"class="ui form" [formGroup]="add" novalidate>
<input type="text" class="text-muted-signature" [formControl]="add.controls['emailaddress']" placeholder="Email" required>
<input type="text" class="text-muted-signature" [formControl]="add.controls['password']" placeholder="Password">
<p>
<button [disabled]="!add.valid" type="submit">add it!</button>
</p>
答案 0 :(得分:0)
似乎没有可以为新注册用户发送电子邮件的模板。查看Create custom email action handler页面,我们只有3种模式可以发送电子邮件到
resetPassword
recoverEmail
verifyEmail
Firebase控制台上也很明显。