forked from baron/baron-sso
fix(backend): resolve signup issues by fixing tenant slug case-sensitivity and exposing Kratos errors
This commit is contained in:
@@ -473,6 +473,8 @@ func (h *AuthHandler) Signup(c *fiber.Ctx) error {
|
|||||||
normalizedPhone = "+" + normalizedPhone
|
normalizedPhone = "+" + normalizedPhone
|
||||||
}
|
}
|
||||||
|
|
||||||
|
slog.Info("[Signup] Phone normalization", "raw", req.Phone, "normalized", normalizedPhone)
|
||||||
|
|
||||||
// IDP에 전달할 BrokerUser 스키마 구성
|
// IDP에 전달할 BrokerUser 스키마 구성
|
||||||
attributes := map[string]interface{}{
|
attributes := map[string]interface{}{
|
||||||
"department": req.Department,
|
"department": req.Department,
|
||||||
@@ -517,7 +519,8 @@ func (h *AuthHandler) Signup(c *fiber.Ctx) error {
|
|||||||
if strings.Contains(err.Error(), "already exists") {
|
if strings.Contains(err.Error(), "already exists") {
|
||||||
return errorJSON(c, fiber.StatusConflict, "User already exists")
|
return errorJSON(c, fiber.StatusConflict, "User already exists")
|
||||||
}
|
}
|
||||||
return errorJSON(c, fiber.StatusInternalServerError, "Failed to create user")
|
// Include the actual error message in the response for debugging
|
||||||
|
return errorJSON(c, fiber.StatusInternalServerError, fmt.Sprintf("Failed to create user: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Cleanup Redis
|
// 4. Cleanup Redis
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package repository
|
|||||||
import (
|
import (
|
||||||
"baron-sso-backend/internal/domain"
|
"baron-sso-backend/internal/domain"
|
||||||
"context"
|
"context"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
@@ -45,7 +46,7 @@ func (r *tenantRepository) FindByID(ctx context.Context, id string) (*domain.Ten
|
|||||||
|
|
||||||
func (r *tenantRepository) FindBySlug(ctx context.Context, slug string) (*domain.Tenant, error) {
|
func (r *tenantRepository) FindBySlug(ctx context.Context, slug string) (*domain.Tenant, error) {
|
||||||
var tenant domain.Tenant
|
var tenant domain.Tenant
|
||||||
if err := r.db.WithContext(ctx).Preload("Domains").Where("slug = ?", slug).First(&tenant).Error; err != nil {
|
if err := r.db.WithContext(ctx).Preload("Domains").Where("slug = ?", strings.ToLower(slug)).First(&tenant).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &tenant, nil
|
return &tenant, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user