feat: resolve auth identity migration reports
This commit is contained in:
@@ -7,6 +7,7 @@ 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"
|
||||
@@ -82,6 +83,10 @@ 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:
|
||||
@@ -252,6 +257,40 @@ 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