Require sign-in for places
Deploy with Docker Compose / deploy (push) Successful in 56s

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 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UKvnE448c1FeepmxZkTezz
This commit is contained in:
2026-09-14 19:58:43 +01:00
co-authored by Claude Opus 5
parent fe6fc02b6b
commit ebb28532c3
3 changed files with 33 additions and 22 deletions
+9 -6
View File
@@ -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