feat: support send ali code
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/database"
|
||||
"quyun/v2/database/models"
|
||||
"quyun/v2/providers/ali"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/samber/lo"
|
||||
@@ -28,6 +29,7 @@ type users struct {
|
||||
|
||||
lastSentAtByPhone map[string]time.Time `inject:"false"`
|
||||
codeByPhone map[string]phoneCodeEntry `inject:"false"`
|
||||
smsNotifyClient *ali.SMSNotifyClient
|
||||
}
|
||||
|
||||
// prepare
|
||||
@@ -310,8 +312,9 @@ func (m *users) SendPhoneCode(ctx context.Context, phone string) error {
|
||||
return errors.New("验证码发送过于频繁,请稍后再试")
|
||||
}
|
||||
|
||||
code, err := m.gen4Digits()
|
||||
code, err := m.smsNotifyClient.SendTo(phone)
|
||||
if err != nil {
|
||||
log.WithError(err).Errorf("SendPhoneCode to %s", phone)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -324,7 +327,6 @@ func (m *users) SendPhoneCode(ctx context.Context, phone string) error {
|
||||
// log phone and code
|
||||
log.Infof("SendPhoneCode to %s: code=%s", phone, code)
|
||||
|
||||
// TODO: 这里应调用实际短信服务商发送 code;当前仅做内存发码与校验支撑。
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user