From ebb28532c3e8f006191abf59740c255bd1beb419 Mon Sep 17 00:00:00 2001 From: Adam French Date: Mon, 14 Sep 2026 19:58:43 +0100 Subject: [PATCH] Require sign-in for places Gate the places query behind an authenticated user so the list is no longer public, and relax the place mutations from admin-only to any signed-in user. Hide the Places tab and skip the fetch entirely for anonymous visitors. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01UKvnE448c1FeepmxZkTezz --- backend/graph/place.resolvers.go | 15 +++++++++------ vue/src/views/home/Collage.vue | 20 ++++++++++++-------- vue/src/views/home/PlacesTable.vue | 20 ++++++++++++-------- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/backend/graph/place.resolvers.go b/backend/graph/place.resolvers.go index ddda2f1..f539d36 100644 --- a/backend/graph/place.resolvers.go +++ b/backend/graph/place.resolvers.go @@ -15,8 +15,8 @@ import ( // CreatePlace is the resolver for the createPlace field. func (r *mutationResolver) CreatePlace(ctx context.Context, input model.CreatePlaceInput) (*models.Place, error) { - if !IsAdminFromCtx(ctx) { - return nil, fmt.Errorf("admin access required") + if _, ok := UserIDFromCtx(ctx); !ok { + return nil, fmt.Errorf("authentication required") } place := models.Place{ Title: input.Title, @@ -40,8 +40,8 @@ func (r *mutationResolver) CreatePlace(ctx context.Context, input model.CreatePl // UpdatePlace is the resolver for the updatePlace field. func (r *mutationResolver) UpdatePlace(ctx context.Context, id int, input model.UpdatePlaceInput) (*models.Place, error) { - if !IsAdminFromCtx(ctx) { - return nil, fmt.Errorf("admin access required") + if _, ok := UserIDFromCtx(ctx); !ok { + return nil, fmt.Errorf("authentication required") } var place models.Place if err := r.Store.DB.First(&place, id).Error; err != nil { @@ -79,8 +79,8 @@ func (r *mutationResolver) UpdatePlace(ctx context.Context, id int, input model. // DeletePlace is the resolver for the deletePlace field. func (r *mutationResolver) DeletePlace(ctx context.Context, id int) (*models.Place, error) { - if !IsAdminFromCtx(ctx) { - return nil, fmt.Errorf("admin access required") + if _, ok := UserIDFromCtx(ctx); !ok { + return nil, fmt.Errorf("authentication required") } var place models.Place if err := r.Store.DB.First(&place, id).Error; err != nil { @@ -99,6 +99,9 @@ func (r *placeResolver) ID(ctx context.Context, obj *models.Place) (int, error) // Places is the resolver for the places field. func (r *queryResolver) Places(ctx context.Context) ([]*models.Place, error) { + if _, ok := UserIDFromCtx(ctx); !ok { + return nil, fmt.Errorf("authentication required") + } var places []models.Place if err := r.Store.DB.Order("done ASC, priority DESC, created_at DESC").Find(&places).Error; err != nil { return nil, err diff --git a/vue/src/views/home/Collage.vue b/vue/src/views/home/Collage.vue index fbf7c21..9b614e7 100644 --- a/vue/src/views/home/Collage.vue +++ b/vue/src/views/home/Collage.vue @@ -1,5 +1,5 @@