初步完成用户电子邮箱绑定(激活)

This commit is contained in:
刘祥超
2022-12-08 20:25:46 +08:00
parent 781c851571
commit 1ab849d9b0
23 changed files with 302 additions and 161 deletions

View File

@@ -340,7 +340,7 @@ func (this *UserDAO) ListEnabledUserIds(tx *dbs.Tx, offset, size int64) ([]int64
return result, nil
}
// CheckUserPassword 检查用户名密码
// CheckUserPassword 检查用户名+密码
func (this *UserDAO) CheckUserPassword(tx *dbs.Tx, username string, encryptedPassword string) (int64, error) {
if len(username) == 0 || len(encryptedPassword) == 0 {
return 0, nil
@@ -354,6 +354,20 @@ func (this *UserDAO) CheckUserPassword(tx *dbs.Tx, username string, encryptedPas
FindInt64Col(0)
}
// CheckUserEmailPassword 检查邮箱+密码
func (this *UserDAO) CheckUserEmailPassword(tx *dbs.Tx, verifiedEmail string, encryptedPassword string) (int64, error) {
if len(verifiedEmail) == 0 || len(encryptedPassword) == 0 {
return 0, nil
}
return this.Query(tx).
Attr("verifiedEmail", verifiedEmail).
Attr("password", encryptedPassword).
Attr("state", UserStateEnabled).
Attr("isOn", true).
ResultPk().
FindInt64Col(0)
}
// FindUserClusterId 查找用户所在集群
func (this *UserDAO) FindUserClusterId(tx *dbs.Tx, userId int64) (int64, error) {
return this.Query(tx).
@@ -586,6 +600,30 @@ func (this *UserDAO) RenewUserServersState(tx *dbs.Tx, userId int64) (bool, erro
return newServersEnabled, nil
}
// FindUserIdWithVerifiedEmail 使用验证后Email查找用户ID
func (this *UserDAO) FindUserIdWithVerifiedEmail(tx *dbs.Tx, verifiedEmail string) (int64, error) {
if len(verifiedEmail) == 0 {
}
return this.Query(tx).
ResultPk().
State(UserStateEnabled).
Attr("verifiedEmail", verifiedEmail).
FindInt64Col(0)
}
// UpdateUserVerifiedEmail 修改已激活邮箱
func (this *UserDAO) UpdateUserVerifiedEmail(tx *dbs.Tx, userId int64, verifiedEmail string) error {
if userId <= 0 {
return nil
}
return this.Query(tx).
Pk(userId).
Set("verifiedEmail", verifiedEmail).
Set("emailIsVerified", true).
UpdateQuickly()
}
// NotifyUpdate 用户变更通知
func (this *UserDAO) NotifyUpdate(tx *dbs.Tx, userId int64) error {
if userId <= 0 {