Skip to content

Commit

Permalink
{fix} - 회원 가입시 서버 에러 해결 \n
Browse files Browse the repository at this point in the history
  • Loading branch information
JokerTrickster committed Oct 28, 2024
1 parent 1265d6b commit efa4fb2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/features/auth/model/interface/IAuthRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

type ISignupAuthRepository interface {
UserCheckByEmail(ctx context.Context, email string) error
InsertOneUser(ctx context.Context, user mysql.Users) error
InsertOneUser(ctx context.Context, user mysql.Users) (uint, error)
SaveToken(ctx context.Context, uID uint, accessToken, refreshToken string, refreshTknExpiredAt int64) error
DeleteToken(ctx context.Context, uID uint) error
VerifyAuthCode(ctx context.Context, email, code string) error
Expand Down
8 changes: 4 additions & 4 deletions src/features/auth/repository/signupAuthRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ func (g *SignupAuthRepository) UserCheckByEmail(ctx context.Context, email strin
return utils.ErrorMsg(ctx, utils.ErrUserAlreadyExisted, utils.Trace(), utils.HandleError(_errors.ErrUserAlreadyExisted.Error(), email), utils.ErrFromClient)
}
}
func (g *SignupAuthRepository) InsertOneUser(ctx context.Context, user mysql.Users) error {
func (g *SignupAuthRepository) InsertOneUser(ctx context.Context, user mysql.Users) (uint, error) {
result := g.GormDB.WithContext(ctx).Create(&user)
if result.RowsAffected == 0 {
return utils.ErrorMsg(ctx, utils.ErrInternalDB, utils.Trace(), utils.HandleError("failed user insert", user), utils.ErrFromMysqlDB)
return 0, utils.ErrorMsg(ctx, utils.ErrInternalDB, utils.Trace(), utils.HandleError("failed user insert", user), utils.ErrFromMysqlDB)
}
if result.Error != nil {
return utils.ErrorMsg(ctx, utils.ErrInternalDB, utils.Trace(), utils.HandleError(result.Error.Error(), user), utils.ErrFromMysqlDB)
return 0, utils.ErrorMsg(ctx, utils.ErrInternalDB, utils.Trace(), utils.HandleError(result.Error.Error(), user), utils.ErrFromMysqlDB)
}
return nil
return user.ID, nil
}

func (g *SignupAuthRepository) VerifyAuthCode(ctx context.Context, email, code string) error {
Expand Down
4 changes: 2 additions & 2 deletions src/features/auth/usecase/signupAuthUseCase.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ func (d *SignupAuthUseCase) Signup(c context.Context, req *request.ReqSignup) (r
user := CreateSignupUser(req)

// 유저 정보 insert
err = d.Repository.InsertOneUser(ctx, user)
uID, err := d.Repository.InsertOneUser(ctx, user)
if err != nil {
return response.ResSignup{}, err
}

user.ID = uID
// token create
accessToken, _, refreshToken, refreshTknExpiredAt, err := utils.GenerateToken(user.Email, user.ID)
if err != nil {
Expand Down

0 comments on commit efa4fb2

Please sign in to comment.