UPDATE: Fix bug
All checks were successful
Build and Release / release (push) Successful in 1m11s

This commit is contained in:
2026-04-27 23:41:41 +07:00
parent 17aafacbfd
commit b168a343be
2 changed files with 20 additions and 4 deletions

View File

@@ -447,6 +447,10 @@ func (a *authService) SigninWithGoogle(ctx context.Context, dto *request.SigninW
if err != nil { if err != nil {
return nil, fiber.NewError(fiber.StatusInternalServerError, "Failed to update refresh token") return nil, fiber.NewError(fiber.StatusInternalServerError, "Failed to update refresh token")
} }
err = tx.Commit(ctx)
if err != nil {
return nil, fiber.NewError(fiber.StatusInternalServerError, "Failed to commit Google signin")
}
return data, nil return data, nil
} }

View File

@@ -32,6 +32,7 @@ func SeedSuperAdmin(pool *pgxpool.Pool) error {
} }
q := sqlc.New(pool) q := sqlc.New(pool)
_, err = q.GetUserByEmail(ctx, email) _, err = q.GetUserByEmail(ctx, email)
if err == nil { if err == nil {
@@ -42,12 +43,20 @@ func SeedSuperAdmin(pool *pgxpool.Pool) error {
return err return err
} }
tx, err := pool.Begin(ctx)
if err != nil {
return err
}
defer tx.Rollback(ctx)
repo := q.WithTx(tx)
hashed, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) hashed, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
if err != nil { if err != nil {
return err return err
} }
user, err := q.UpsertUser(ctx, sqlc.UpsertUserParams{ user, err := repo.UpsertUser(ctx, sqlc.UpsertUserParams{
Email: email, Email: email,
PasswordHash: pgtype.Text{ PasswordHash: pgtype.Text{
String: string(hashed), String: string(hashed),
@@ -59,7 +68,7 @@ func SeedSuperAdmin(pool *pgxpool.Pool) error {
return err return err
} }
_, err = q.CreateUserProfile(ctx, sqlc.CreateUserProfileParams{ _, err = repo.CreateUserProfile(ctx, sqlc.CreateUserProfileParams{
UserID: user.ID, UserID: user.ID,
DisplayName: pgtype.Text{ DisplayName: pgtype.Text{
String: displayName, String: displayName,
@@ -80,7 +89,7 @@ func SeedSuperAdmin(pool *pgxpool.Pool) error {
return err return err
} }
err = q.CreateUserRole( err = repo.CreateUserRole(
ctx, ctx,
sqlc.CreateUserRoleParams{ sqlc.CreateUserRoleParams{
UserID: user.ID, UserID: user.ID,
@@ -91,6 +100,9 @@ func SeedSuperAdmin(pool *pgxpool.Pool) error {
return err return err
} }
return nil if err := tx.Commit(ctx); err != nil {
return err
}
return nil
} }