diff --git a/model/gmodel/fs_user_logic.go b/model/gmodel/fs_user_logic.go index f352abf1..05e3dabf 100644 --- a/model/gmodel/fs_user_logic.go +++ b/model/gmodel/fs_user_logic.go @@ -101,6 +101,8 @@ func (u *FsUserModel) RegisterByGoogleOAuth(ctx context.Context, token *auth.Reg err := u.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error { googleId := token.Extend["google_id"].(int64) + firstName := token.Extend["first_name"].(string) + lastName := token.Extend["last_name"].(string) err := tx.Model(&FsUser{}).Where("email = ?", token.Email).Take(user).Error if err != nil { @@ -111,6 +113,8 @@ func (u *FsUserModel) RegisterByGoogleOAuth(ctx context.Context, token *auth.Reg user.CreatedAt = &createAt user.GoogleId = &googleId user.PasswordHash = &token.Password + user.FirstName = &firstName + user.FirstName = &lastName err = tx.Model(&FsUser{}).Create(user).Error if err != nil { return err diff --git a/server/auth/internal/logic/useremailconfirmationlogic.go b/server/auth/internal/logic/useremailconfirmationlogic.go index 05fafc03..3bfb83c0 100644 --- a/server/auth/internal/logic/useremailconfirmationlogic.go +++ b/server/auth/internal/logic/useremailconfirmationlogic.go @@ -111,7 +111,7 @@ func (l *UserEmailConfirmationLogic) UserEmailConfirmation(req *types.RequestEma return resp.SetStatusWithMessage(basic.CodeOAuthConfirmationTimeoutErr, "Verification links expire after 30 minute.") } - logx.Info(token.Platform) + logx.Error(token.Platform) switch token.Platform { case string(auth.PLATFORM_GOOGLE): // 谷歌平台的注册流程 diff --git a/server/auth/internal/logic/usergoogleloginlogic.go b/server/auth/internal/logic/usergoogleloginlogic.go index 02cf6658..440c84a2 100644 --- a/server/auth/internal/logic/usergoogleloginlogic.go +++ b/server/auth/internal/logic/usergoogleloginlogic.go @@ -72,9 +72,10 @@ func (l *UserGoogleLoginLogic) UserGoogleLogin(req *types.RequestGoogleLogin, us return resp.SetStatus(basic.CodeOAuthGoogleApiErr, err.Error()) } - logx.Error(r.Json()) + gresult := r.Json() + logx.Info(gresult) - googleId := r.Json().Get("id").Int() + googleId := gresult.Get("id").Int() user, err := l.svcCtx.AllModels.FsUser.FindUserByGoogleId(context.TODO(), googleId) if err != nil { if err != gorm.ErrRecordNotFound { @@ -96,8 +97,8 @@ func (l *UserGoogleLoginLogic) UserGoogleLogin(req *types.RequestGoogleLogin, us CreateAt: time.Now().UTC(), Extend: map[string]interface{}{ "google_id": googleId, - "first_name": "", - "last_name": "", + "first_name": gresult.Get("family_name"), + "last_name": gresult.Get("given_name"), }, }