fix
This commit is contained in:
parent
122c850d2e
commit
b9447dae4d
@ -147,17 +147,8 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT
|
|||||||
|
|
||||||
err := u.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
err := u.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||||
var err error
|
var err error
|
||||||
defer func() {
|
|
||||||
if err == gorm.ErrRecordNotFound {
|
|
||||||
err = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
}()
|
|
||||||
|
|
||||||
UserTx := tx.Model(user)
|
UserTx := tx.Model(user)
|
||||||
err = UserTx.Where("email = ?", token.Email).Take(user).Error
|
err = UserTx.Where("email = ?", token.Email).Take(user).Error
|
||||||
if err != nil {
|
|
||||||
// 没有找到在数据库就创建注册
|
|
||||||
if err == gorm.ErrRecordNotFound {
|
if err == gorm.ErrRecordNotFound {
|
||||||
|
|
||||||
FirstName := token.Extend["first_name"].(string)
|
FirstName := token.Extend["first_name"].(string)
|
||||||
@ -172,11 +163,13 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT
|
|||||||
user.LastName = &LastName
|
user.LastName = &LastName
|
||||||
|
|
||||||
err = UserTx.Create(user).Error
|
err = UserTx.Create(user).Error
|
||||||
logcontent += "create."
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logcontent += "create."
|
||||||
if token.GuestId != 0 {
|
if token.GuestId != 0 {
|
||||||
// 继承guest_id的资源表
|
// 继承guest_id的资源表
|
||||||
err = InheritGuestIdResource(tx, user.Id, token.GuestId, func(txResouce, txUserMaterial, txUserInfo *gorm.DB) error {
|
err = InheritGuestIdResource(tx, user.Id, token.GuestId, func(txResouce, txUserMaterial, txUserInfo *gorm.DB) error {
|
||||||
@ -201,29 +194,16 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT
|
|||||||
logcontent += "profile."
|
logcontent += "profile."
|
||||||
return txUserInfo.Create(uinfo).Error
|
return txUserInfo.Create(uinfo).Error
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
if err == gorm.ErrRecordNotFound {
|
if err == gorm.ErrRecordNotFound {
|
||||||
err = nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err == gorm.ErrRecordNotFound {
|
|
||||||
err = nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err == nil {
|
|
||||||
return fmt.Errorf("the email had registered")
|
return fmt.Errorf("the email had registered")
|
||||||
}
|
|
||||||
|
|
||||||
if err == gorm.ErrRecordNotFound {
|
|
||||||
err = nil
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil && err != gorm.ErrRecordNotFound {
|
if err != nil && err != gorm.ErrRecordNotFound {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user