fix: 修复未绑定外部邮箱的新用户登录被二次验证阻断的问题
Some checks are pending
Security Checks / security (push) Waiting to run
Some checks are pending
Security Checks / security (push) Waiting to run
This commit is contained in:
parent
09763448f6
commit
a4dba70d0b
@ -12,6 +12,7 @@ import (
|
||||
"git.pcux.cn/xuans/Smail/dto/response"
|
||||
"git.pcux.cn/xuans/Smail/models"
|
||||
"git.pcux.cn/xuans/Smail/services/access"
|
||||
"git.pcux.cn/xuans/Smail/services/externalemail"
|
||||
"git.pcux.cn/xuans/Smail/services/verification"
|
||||
"git.pcux.cn/xuans/Smail/session"
|
||||
"git.pcux.cn/xuans/Smail/utils/array"
|
||||
@ -91,6 +92,9 @@ func beginLoginVerification(user *models.User, remoteIP string) (map[string]any,
|
||||
}
|
||||
binding, err := runtime.external.FindVerifiedPrimaryByUser(user.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, externalemail.ErrBindingNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, errLoginVerificationUnavailable
|
||||
}
|
||||
email, err := runtime.external.Decrypt(*binding)
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
package controllers
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.pcux.cn/xuans/Smail/models"
|
||||
)
|
||||
|
||||
func TestLoginVerificationPolicyEnabled(t *testing.T) {
|
||||
tests := []struct {
|
||||
@ -24,3 +28,17 @@ func TestLoginVerificationPolicyEnabled(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBeginLoginVerification_NoExternalEmail(t *testing.T) {
|
||||
user := &models.User{
|
||||
ID: 99999,
|
||||
Account: "test_no_email",
|
||||
}
|
||||
res, err := beginLoginVerification(user, "127.0.0.1")
|
||||
if err != nil {
|
||||
t.Fatalf("expected nil error for user without external email, got: %v", err)
|
||||
}
|
||||
if res != nil {
|
||||
t.Fatalf("expected nil challenge result for user without external email, got: %v", res)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user