后台登陆验证码

This commit is contained in:
yml
2026-05-22 17:20:47 +08:00
parent 6edee641fb
commit 7df557d668
12 changed files with 218 additions and 20 deletions
+11 -3
View File
@@ -5,6 +5,7 @@ import "errors"
var (
ErrDependencyUnavailable = errors.New("dependency unavailable")
ErrInvalidCredential = errors.New("invalid credential")
ErrCaptchaInvalid = errors.New("captcha invalid")
ErrAdminDisabled = errors.New("admin disabled")
)
@@ -16,14 +17,21 @@ func NewService(repo *Repository) *Service {
return &Service{repo: repo}
}
func (s *Service) Login(username string, password string) (LoginResult, error) {
func (s *Service) Captcha() (*CaptchaDTO, error) {
if s.repo == nil {
return nil, ErrDependencyUnavailable
}
return s.repo.Captcha()
}
func (s *Service) Login(username string, password string, captchaID string, captchaCode string) (LoginResult, error) {
if s.repo == nil {
return LoginResult{}, ErrDependencyUnavailable
}
if username == "" || password == "" {
if username == "" || password == "" || captchaID == "" || captchaCode == "" {
return LoginResult{}, ErrInvalidCredential
}
return s.repo.Login(username, password)
return s.repo.Login(username, password, captchaID, captchaCode)
}
func (s *Service) Me(adminID uint64) (*AdminDTO, error) {