feature: verify user with sms code (#14858)

Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
Jian Qiu
2022-08-29 15:39:18 +08:00
committed by GitHub
co-authored by Qiu Jian
parent 5261a80df5
commit 872feb5484
+15 -15
View File
@@ -63,6 +63,20 @@ func (self *SubcontactPullTask) OnInit(ctx context.Context, obj db.IStandaloneMo
self.SetStageComplete(ctx, nil)
return
}
// sync email and mobile to keystone
s := auth.GetSession(ctx, self.UserCred, "")
mobile := receiver.Mobile
if strings.HasPrefix(mobile, "+86 ") {
mobile = strings.TrimSpace(mobile[4:])
}
params := map[string]string{
"email": receiver.Email,
"mobile": receiver.Mobile,
}
_, err := identity.UsersV3.Update(s, receiver.Id, jsonutils.Marshal(params))
if err != nil {
log.Errorf("update user email and mobile fail %s", err)
}
var contactTypes []string
if self.Params.Contains("contact_types") {
jArray, _ := self.Params.Get("contact_types")
@@ -94,7 +108,7 @@ func (self *SubcontactPullTask) OnInit(ctx context.Context, obj db.IStandaloneMo
receiver.MarkContactTypeVerified(cType)
}
// push cache
err := receiver.PushCache(ctx)
err = receiver.PushCache(ctx)
if err != nil {
reason := fmt.Sprintf("PushCache: %v", err)
self.taskFailed(ctx, receiver, reason)
@@ -105,20 +119,6 @@ func (self *SubcontactPullTask) OnInit(ctx context.Context, obj db.IStandaloneMo
self.taskFailed(ctx, receiver, reason)
return
}
// sync email and mobile to keystone
s := auth.GetSession(ctx, self.UserCred, "")
mobile := receiver.Mobile
if strings.HasPrefix(mobile, "+86 ") {
mobile = strings.TrimSpace(mobile[4:])
}
params := map[string]string{
"email": receiver.Email,
"mobile": receiver.Mobile,
}
_, err = identity.UsersV3.Update(s, receiver.Id, jsonutils.Marshal(params))
if err != nil {
log.Errorf("update user email and mobile fail %s", err)
}
// success
receiver.SetStatus(self.UserCred, apis.RECEIVER_STATUS_READY, "")
logclient.AddActionLogWithContext(ctx, receiver, logclient.ACT_PULL_SUBCONTACT, "", self.UserCred, true)