Allow resending email verification (#770)

This commit is contained in:
Paulus Schoutsen 2017-12-29 12:43:28 -08:00 committed by GitHub
parent 0fd84a2f8d
commit eeb949a081
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -122,6 +122,9 @@
on-tap='_handleVerifyEmail'
progress='[[_requestInProgress]]'
>Verify Email</ha-progress-button>
<paper-button
on-tap='_handleResendVerifyEmail'
>Resend Verify Email</paper-button>
</div>
</paper-card>
</template>
@ -233,7 +236,7 @@ class HaConfigCloudRegister extends
confirmation_code: this._confirmationCode,
}).then(() => {
// eslint-disable-next-line
alert('Confirmation successful. You can now login.');
alert('Confirmation successful. You can now login.');
this.navigate('config/cloud/login');
}, (err) => {
this._confirmationCode = '';
@ -242,6 +245,24 @@ class HaConfigCloudRegister extends
this._requestInProgress = false;
});
}
_handleResendVerifyEmail() {
if (!this.email) {
this._error = 'Email is required.';
}
if (this._error) return;
this.hass.callApi('post', 'cloud/resend_confirm', {
email: this.email,
}).then(() => {
// eslint-disable-next-line
alert('Email resend.');
}, (err) => {
this._error = err && err.body && err.body.message ?
err.body.message : 'Unknown error';
});
}
}
customElements.define(HaConfigCloudRegister.is, HaConfigCloudRegister);