feat: complete registration invitation and auth redesign
This commit is contained in:
@@ -214,6 +214,31 @@ func (v *validator) ResetSecret(tenantID t.TenantID, phone, scheme, lang string,
|
||||
return nil
|
||||
}
|
||||
|
||||
// SendCode synchronously delivers a product verification code. Unlike the
|
||||
// legacy credential flow, it fails when no real SMS provider is configured.
|
||||
func (v *validator) SendCode(_ t.TenantID, phone, lang, scene, code string) error {
|
||||
if v.Twilio == nil {
|
||||
return t.ErrUnsupported
|
||||
}
|
||||
var template *textt.Template
|
||||
if v.langMatcher != nil {
|
||||
_, idx := i18n.MatchStrings(v.langMatcher, lang)
|
||||
template = v.universalTempl[idx]
|
||||
} else if len(v.universalTempl) > 0 {
|
||||
template = v.universalTempl[0]
|
||||
}
|
||||
if template == nil {
|
||||
return t.ErrInternal
|
||||
}
|
||||
content, err := validate.ExecuteTemplate(template, nil, map[string]any{
|
||||
"Code": code, "HostUrl": v.HostUrl, "Scene": scene,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return twilioSend(v.Sender, phone, content[""])
|
||||
}
|
||||
|
||||
// Check checks validity of user's response.
|
||||
func (v *validator) Check(tenantID t.TenantID, user t.Uid, resp string) (string, error) {
|
||||
cred, err := store.Users.GetActiveCred(tenantID, user, validatorName)
|
||||
|
||||
Reference in New Issue
Block a user