forked from baron/baron-sso
사용자 상태 세분화
This commit is contained in:
@@ -1644,10 +1644,9 @@ func (h *UserHandler) BulkUpdateUsers(c *fiber.Ctx) error {
|
||||
|
||||
state := identity.State
|
||||
if req.Status != nil {
|
||||
if *req.Status == "active" {
|
||||
state = "active"
|
||||
} else {
|
||||
state = "inactive"
|
||||
state = normalizeKratosState(req.Status)
|
||||
if state == "" {
|
||||
state = identity.State
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1667,7 +1666,7 @@ func (h *UserHandler) BulkUpdateUsers(c *fiber.Ctx) error {
|
||||
localUser.Role = *req.Role
|
||||
}
|
||||
if req.Status != nil {
|
||||
localUser.Status = *req.Status
|
||||
localUser.Status = normalizeStatus(*req.Status)
|
||||
}
|
||||
if req.Department != nil {
|
||||
localUser.Department = *req.Department
|
||||
@@ -2610,20 +2609,7 @@ func formatTime(value time.Time) string {
|
||||
}
|
||||
|
||||
func normalizeStatus(state string) string {
|
||||
state = strings.ToLower(strings.TrimSpace(state))
|
||||
if state == "blocked" {
|
||||
return domain.UserStatusInactive
|
||||
}
|
||||
if state == domain.UserStatusInactive ||
|
||||
state == domain.UserStatusSuspended ||
|
||||
state == domain.UserStatusLeaveOfAbsence ||
|
||||
state == domain.UserStatusActive {
|
||||
return state
|
||||
}
|
||||
if state == "" {
|
||||
return domain.UserStatusActive
|
||||
}
|
||||
return state
|
||||
return domain.NormalizeUserStatus(state)
|
||||
}
|
||||
|
||||
func normalizeKratosState(status *string) string {
|
||||
@@ -2637,9 +2623,13 @@ func normalizeKratosState(status *string) string {
|
||||
if value == domain.UserStatusActive {
|
||||
return domain.UserStatusActive
|
||||
}
|
||||
if value == domain.UserStatusInactive ||
|
||||
value == domain.UserStatusSuspended ||
|
||||
value == domain.UserStatusLeaveOfAbsence {
|
||||
normalized := domain.NormalizeUserStatus(value)
|
||||
if normalized == domain.UserStatusPreboarding ||
|
||||
normalized == domain.UserStatusSuspended ||
|
||||
normalized == domain.UserStatusTemporaryLeave ||
|
||||
normalized == domain.UserStatusBaronGuest ||
|
||||
normalized == domain.UserStatusExtendedLeave ||
|
||||
normalized == domain.UserStatusArchived {
|
||||
return domain.UserStatusInactive
|
||||
}
|
||||
return ""
|
||||
|
||||
Reference in New Issue
Block a user