From 872feb548412b96200f37a599344a05d8caa273f Mon Sep 17 00:00:00 2001 From: Jian Qiu Date: Mon, 29 Aug 2022 15:39:18 +0800 Subject: [PATCH] feature: verify user with sms code (#14858) Co-authored-by: Qiu Jian --- pkg/notify/tasks/subcontact_pull_task.go | 30 ++++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pkg/notify/tasks/subcontact_pull_task.go b/pkg/notify/tasks/subcontact_pull_task.go index 5dc4ecf2bd..8a3a6015b7 100644 --- a/pkg/notify/tasks/subcontact_pull_task.go +++ b/pkg/notify/tasks/subcontact_pull_task.go @@ -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)