Skip to content

Commit

Permalink
Merge pull request #375 from actiontech/fix_two_factor_bug
Browse files Browse the repository at this point in the history
fix: update two factor enabled failed
  • Loading branch information
LordofAvernus authored Feb 21, 2025
2 parents 4e644f9 + 5218690 commit 4ec83b0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion internal/dms/biz/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ func (d *UserUsecase) UpdateUser(ctx context.Context, currentUserUid, updateUser
return nil
}

func (d *UserUsecase) UpdateCurrentUser(ctx context.Context, currentUserUid string, oldPassword, password, email, phone, wxId, language *string) error {
func (d *UserUsecase) UpdateCurrentUser(ctx context.Context, currentUserUid string, oldPassword, password, email, phone, wxId, language *string, twoFactorEnabled *bool) error {
user, err := d.GetUser(ctx, currentUserUid)
if err != nil {
return fmt.Errorf("get user failed: %v", err)
Expand Down Expand Up @@ -826,6 +826,9 @@ func (d *UserUsecase) UpdateCurrentUser(ctx context.Context, currentUserUid stri
if language != nil {
user.Language = *language
}
if twoFactorEnabled != nil {
user.TwoFactorEnabled = *twoFactorEnabled
}

if err := d.repo.UpdateUser(ctx, user); nil != err {
return fmt.Errorf("update current user error: %v", err)
Expand Down
3 changes: 2 additions & 1 deletion internal/dms/service/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (d *DMSService) UpdateUser(ctx context.Context, req *dmsV1.UpdateUserReq, c
}

func (d *DMSService) UpdateCurrentUser(ctx context.Context, req *dmsV1.UpdateCurrentUserReq, currentUserUid string) (err error) {
if err = d.UserUsecase.UpdateCurrentUser(ctx, currentUserUid, req.User.OldPassword, req.User.Password, req.User.Email, req.User.Phone, req.User.WxID, req.User.Language); nil != err {
if err = d.UserUsecase.UpdateCurrentUser(ctx, currentUserUid, req.User.OldPassword, req.User.Password, req.User.Email, req.User.Phone, req.User.WxID, req.User.Language, req.User.TwoFactorEnabled); nil != err {
return fmt.Errorf("update user failed: %v", err)
}

Expand Down Expand Up @@ -452,6 +452,7 @@ func (d *DMSService) GetUser(ctx context.Context, req *dmsCommonV1.GetUserReq) (
Phone: u.Phone,
WxID: u.WxID,
Language: u.Language,
TwoFactorEnabled: u.TwoFactorEnabled,
ThirdPartyUserInfo: u.ThirdPartyUserInfo,
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/dms-common/api/dms/v1/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type GetUser struct {
Language string `json:"language"`
// user stat
Stat Stat `json:"stat"`
// user two factor enabled
TwoFactorEnabled bool `json:"two_factor_enabled"`
// user authentication type
AuthenticationType UserAuthenticationType `json:"authentication_type"`
// user groups
Expand Down

0 comments on commit 4ec83b0

Please sign in to comment.