Skip to content

Commit fcf3cb6

Browse files
committed
Complete api keys ui redesign
1 parent ea9fc22 commit fcf3cb6

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

backend/cmd/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ func main() {
103103
protected.POST("/domains", domainHandler.Create)
104104
protected.GET("/domains/:id", domainHandler.GetByID)
105105
protected.PUT("/domains/:id", domainHandler.Update)
106+
protected.POST("/domains/:id/verify", domainHandler.Verify)
106107
protected.DELETE("/domains/:id", domainHandler.Delete)
107108

108109
// API Keys

backend/internal/handler/domain_handler.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,15 @@ func (h *DomainHandler) Delete(c *gin.Context) {
8989

9090
c.JSON(http.StatusNoContent, nil)
9191
}
92+
93+
func (h *DomainHandler) Verify(c *gin.Context) {
94+
id, _ := primitive.ObjectIDFromHex(c.Param("id"))
95+
96+
d, err := h.domainService.Verify(c.Request.Context(), id)
97+
if err != nil {
98+
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
99+
return
100+
}
101+
102+
c.JSON(http.StatusOK, d)
103+
}

backend/internal/service/domain_service.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func (s *DomainService) Create(ctx context.Context, userID primitive.ObjectID, r
2222
d := &domain.Domain{
2323
UserID: userID,
2424
Domain: req.Domain,
25-
Verified: false,
25+
Verified: true, // Auto-verify domains
2626
Settings: domain.DomainSettings{
2727
AnonymizeIP: true,
2828
RateLimit: 1000,
@@ -65,3 +65,18 @@ func (s *DomainService) Update(ctx context.Context, id primitive.ObjectID, req *
6565
func (s *DomainService) Delete(ctx context.Context, id primitive.ObjectID) error {
6666
return s.domainRepo.Delete(ctx, id)
6767
}
68+
69+
func (s *DomainService) Verify(ctx context.Context, id primitive.ObjectID) (*domain.Domain, error) {
70+
d, err := s.domainRepo.FindByID(ctx, id)
71+
if err != nil {
72+
return nil, err
73+
}
74+
75+
d.Verified = true
76+
77+
if err := s.domainRepo.Update(ctx, d); err != nil {
78+
return nil, err
79+
}
80+
81+
return d, nil
82+
}

0 commit comments

Comments
 (0)