forked from baron/baron-sso
로그인 페이지 및 기능 구현
This commit is contained in:
@@ -31,3 +31,31 @@ type QRInitResponse struct {
|
||||
PendingRef string `json:"pendingRef"`
|
||||
ExpiresIn int `json:"expiresIn"`
|
||||
}
|
||||
|
||||
// Signup Flow Models
|
||||
|
||||
type CheckEmailRequest struct {
|
||||
Email string `json:"email"`
|
||||
}
|
||||
|
||||
type SendSignupCodeRequest struct {
|
||||
Target string `json:"target"` // Email or Phone
|
||||
Type string `json:"type"` // "email" or "phone"
|
||||
}
|
||||
|
||||
type VerifySignupCodeRequest struct {
|
||||
Target string `json:"target"` // Email or Phone
|
||||
Type string `json:"type"` // "email" or "phone"
|
||||
Code string `json:"code"`
|
||||
}
|
||||
|
||||
type SignupRequest struct {
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password"`
|
||||
Name string `json:"name"`
|
||||
Phone string `json:"phone"`
|
||||
AffiliationType string `json:"affiliationType"` // "AFFILIATE" or "GENERAL"
|
||||
CompanyCode string `json:"companyCode,omitempty"`
|
||||
Department string `json:"department"`
|
||||
TermsAccepted bool `json:"termsAccepted"`
|
||||
}
|
||||
|
||||
@@ -97,6 +97,11 @@ func (h *AuthHandler) CheckEmail(c *fiber.Ctx) error {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "Invalid request"})
|
||||
}
|
||||
|
||||
// Email Format Validation
|
||||
if !strings.Contains(req.Email, "@") || !strings.Contains(req.Email, ".") {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "Invalid email format"})
|
||||
}
|
||||
|
||||
if h.DescopeClient == nil {
|
||||
return c.Status(fiber.StatusServiceUnavailable).JSON(fiber.Map{"error": "Identity provider unavailable"})
|
||||
}
|
||||
@@ -366,7 +371,7 @@ func (h *AuthHandler) Signup(c *fiber.Ctx) error {
|
||||
slog.Error("[Signup] Failed to set password", "error", err)
|
||||
// Rollback? Delete user?
|
||||
h.DescopeClient.Management.User().Delete(context.Background(), req.Email)
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Failed to set password"})
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": fmt.Sprintf("Failed to set password: %v", err)})
|
||||
}
|
||||
|
||||
// 4. Cleanup Redis
|
||||
|
||||
@@ -30,6 +30,10 @@ func NewRedisService() (*RedisService, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// [DEV-FIX] Disable stop-writes-on-bgsave-error to allow writes even if persistence fails
|
||||
// This is common in dev docker environments with permission issues.
|
||||
rdb.ConfigSet(ctx, "stop-writes-on-bgsave-error", "no")
|
||||
|
||||
return &RedisService{Client: rdb}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user