forked from baron/baron-sso
개발자 등록 신청 입력 안내 및 역할 표기 개선
This commit is contained in:
@@ -2800,7 +2800,17 @@ func (h *DevHandler) ListMyTenants(c *fiber.Ctx) error {
|
||||
|
||||
role := normalizeUserRole(profile.Role)
|
||||
if role == domain.RoleUser {
|
||||
return errorJSON(c, fiber.StatusForbidden, "access denied")
|
||||
if profile.TenantID == nil || strings.TrimSpace(*profile.TenantID) == "" {
|
||||
return c.JSON([]domain.Tenant{})
|
||||
}
|
||||
tenant, err := h.TenantSvc.GetTenant(c.Context(), *profile.TenantID)
|
||||
if err != nil {
|
||||
return errorJSON(c, fiber.StatusInternalServerError, "failed to get tenant")
|
||||
}
|
||||
if tenant == nil {
|
||||
return c.JSON([]domain.Tenant{})
|
||||
}
|
||||
return c.JSON([]domain.Tenant{*tenant})
|
||||
}
|
||||
|
||||
if role == domain.RoleSuperAdmin {
|
||||
@@ -2839,6 +2849,12 @@ func (h *DevHandler) RequestDeveloperAccess(c *fiber.Ctx) error {
|
||||
if profile == nil {
|
||||
return errorJSON(c, fiber.StatusUnauthorized, "unauthorized")
|
||||
}
|
||||
if h.Auth != nil {
|
||||
if enriched, err := h.Auth.GetEnrichedProfile(c); err == nil && enriched != nil {
|
||||
profile = enriched
|
||||
c.Locals("user_profile", enriched)
|
||||
}
|
||||
}
|
||||
|
||||
var req struct {
|
||||
Name string `json:"name"`
|
||||
@@ -2857,11 +2873,25 @@ func (h *DevHandler) RequestDeveloperAccess(c *fiber.Ctx) error {
|
||||
return errorJSON(c, fiber.StatusBadRequest, "tenantId is required")
|
||||
}
|
||||
|
||||
name := strings.TrimSpace(profile.Name)
|
||||
if name == "" {
|
||||
name = strings.TrimSpace(req.Name)
|
||||
}
|
||||
organization := strings.TrimSpace(req.Organization)
|
||||
if h.TenantSvc != nil {
|
||||
if tenant, err := h.TenantSvc.GetTenant(c.Context(), req.TenantID); err == nil && tenant != nil && strings.TrimSpace(tenant.Name) != "" {
|
||||
organization = strings.TrimSpace(tenant.Name)
|
||||
}
|
||||
}
|
||||
|
||||
devReq := domain.DeveloperRequest{
|
||||
UserID: profile.ID,
|
||||
TenantID: req.TenantID,
|
||||
Name: req.Name,
|
||||
Organization: req.Organization,
|
||||
Name: name,
|
||||
Organization: organization,
|
||||
Email: profile.Email,
|
||||
Phone: profile.Phone,
|
||||
Role: normalizeUserRole(profile.Role),
|
||||
Reason: req.Reason,
|
||||
Status: domain.DeveloperRequestStatusPending,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user