邮箱
- 前提条件
- 注册
- 密码登录
- 验证码登录
- 修改邮箱地址
- 修改密码
- 重置密码
- 更多信息
前提条件
注册
一、在使用邮箱注册之前,需要先验证您的邮箱,确保该邮箱帐户归您所有。
调用AGConnectAuth.requestEmailVerifyCode申请验证码。
import { EmailAuthProvider, VerifyCodeAction, VerifyCodeSettingBuilder, PhoneUserBuilder,
PhoneAuthProvider, AGConnectAuth, AGConnectAuthCredentialProvider
} from "@hw-agconnect/auth-ohos"
import agconnect from '@hw-agconnect/api-ohos'
@Entry
@Component
struct LoginPage {
@State countDown:number = 60
@State isRegister:boolean = false
@State emailText:string = '321578850@qq.com'
private timer = null
/*
* 发送验证码
* */
async sendCode() {
this.startCountDown()
const verifyCodeSettings = new VerifyCodeSettingBuilder()
.setAction(VerifyCodeAction.REGISTER_LOGIN)
.setLang('zh_CN')
.setSendInterval(60)
.build();
await agconnect.auth().requestEmailVerifyCode(this.emailText, verifyCodeSettings)
.then(verifyCodeResult => {
//验证码申请成功
console.log(JSON.stringify(verifyCodeResult), '成功')
}).catch(error => {
//验证码申请失败
console.log(JSON.stringify(error), '失败')
});
}
二、验证码发送成功
发送验证码时请使用模拟器进行发送,预览器发送验证码会失败
欢迎关注【邵洛】,后面内容持续更新~