refactor(admin): remove auth migration reports
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
|
||||
"github.com/Wei-Shaw/sub2api/internal/handler/dto"
|
||||
"github.com/Wei-Shaw/sub2api/internal/pkg/response"
|
||||
servermiddleware "github.com/Wei-Shaw/sub2api/internal/server/middleware"
|
||||
"github.com/Wei-Shaw/sub2api/internal/service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -83,10 +82,6 @@ type BindUserAuthIdentityChannelRequest struct {
|
||||
Metadata map[string]any `json:"metadata"`
|
||||
}
|
||||
|
||||
type ResolveAuthIdentityMigrationReportRequest struct {
|
||||
ResolutionNote string `json:"resolution_note"`
|
||||
}
|
||||
|
||||
// List handles listing all users with pagination
|
||||
// GET /api/v1/admin/users
|
||||
// Query params:
|
||||
@@ -193,31 +188,6 @@ func (h *UserHandler) GetByID(c *gin.Context) {
|
||||
response.Success(c, dto.UserFromServiceAdmin(user))
|
||||
}
|
||||
|
||||
// GetAuthIdentityMigrationReportSummary returns aggregate migration report counts.
|
||||
// GET /api/v1/admin/users/auth-identity-migration-reports/summary
|
||||
func (h *UserHandler) GetAuthIdentityMigrationReportSummary(c *gin.Context) {
|
||||
summary, err := h.adminService.GetAuthIdentityMigrationReportSummary(c.Request.Context())
|
||||
if err != nil {
|
||||
response.ErrorFrom(c, err)
|
||||
return
|
||||
}
|
||||
response.Success(c, summary)
|
||||
}
|
||||
|
||||
// ListAuthIdentityMigrationReports returns paginated auth identity migration reports.
|
||||
// GET /api/v1/admin/users/auth-identity-migration-reports
|
||||
func (h *UserHandler) ListAuthIdentityMigrationReports(c *gin.Context) {
|
||||
page, pageSize := response.ParsePagination(c)
|
||||
reportType := strings.TrimSpace(c.Query("report_type"))
|
||||
|
||||
reports, total, err := h.adminService.ListAuthIdentityMigrationReports(c.Request.Context(), reportType, page, pageSize)
|
||||
if err != nil {
|
||||
response.ErrorFrom(c, err)
|
||||
return
|
||||
}
|
||||
response.Paginated(c, reports, total, page, pageSize)
|
||||
}
|
||||
|
||||
// BindAuthIdentity manually binds a canonical auth identity to a user.
|
||||
// POST /api/v1/admin/users/:id/auth-identities
|
||||
func (h *UserHandler) BindAuthIdentity(c *gin.Context) {
|
||||
@@ -257,40 +227,6 @@ func (h *UserHandler) BindAuthIdentity(c *gin.Context) {
|
||||
response.Success(c, result)
|
||||
}
|
||||
|
||||
// ResolveAuthIdentityMigrationReport marks a migration report as resolved.
|
||||
// POST /api/v1/admin/users/auth-identity-migration-reports/:id/resolve
|
||||
func (h *UserHandler) ResolveAuthIdentityMigrationReport(c *gin.Context) {
|
||||
reportID, err := strconv.ParseInt(c.Param("id"), 10, 64)
|
||||
if err != nil {
|
||||
response.BadRequest(c, "Invalid report ID")
|
||||
return
|
||||
}
|
||||
|
||||
subject, ok := servermiddleware.GetAuthSubjectFromContext(c)
|
||||
if !ok || subject.UserID <= 0 {
|
||||
response.Unauthorized(c, "Authentication required")
|
||||
return
|
||||
}
|
||||
|
||||
var req ResolveAuthIdentityMigrationReportRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
response.BadRequest(c, "Invalid request: "+err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
report, err := h.adminService.ResolveAuthIdentityMigrationReport(
|
||||
c.Request.Context(),
|
||||
reportID,
|
||||
subject.UserID,
|
||||
req.ResolutionNote,
|
||||
)
|
||||
if err != nil {
|
||||
response.ErrorFrom(c, err)
|
||||
return
|
||||
}
|
||||
response.Success(c, report)
|
||||
}
|
||||
|
||||
// Create handles creating a new user
|
||||
// POST /api/v1/admin/users
|
||||
func (h *UserHandler) Create(c *gin.Context) {
|
||||
|
||||
Reference in New Issue
Block a user