From cd0ef906447aa086f2ffbec80ceaf581a39e943c Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 23 Nov 2021 17:59:17 +0000 Subject: [PATCH] Make User.userType @private This allows requests with a private token or a cookie to query this field. --- api/go.mod | 2 +- api/go.sum | 2 ++ api/graph/api/generated.go | 8 ++++---- api/graph/schema.graphqls | 2 +- api/graph/schema.resolvers.go | 8 ++++---- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/api/go.mod b/api/go.mod index eaf0ebb..675d83a 100644 --- a/api/go.mod +++ b/api/go.mod @@ -3,7 +3,7 @@ module git.sr.ht/~sircmpwn/meta.sr.ht/api go 1.14 require ( - git.sr.ht/~sircmpwn/core-go v0.0.0-20210924112641-378fedbc638f // indirect + git.sr.ht/~sircmpwn/core-go v0.0.0-20211124081341-d5f650dadb54 // indirect git.sr.ht/~sircmpwn/dowork v0.0.0-20210820133136-d3970e97def3 // indirect git.sr.ht/~sircmpwn/go-bare v0.0.0-20210227202403-5dae5c48f917 // indirect github.com/99designs/gqlgen v0.13.0 diff --git a/api/go.sum b/api/go.sum index a579f0d..04f2b9f 100644 --- a/api/go.sum +++ b/api/go.sum @@ -66,6 +66,8 @@ git.sr.ht/~sircmpwn/core-go v0.0.0-20210924111216-3b553750746e h1:+5NgeBztmqDkcR git.sr.ht/~sircmpwn/core-go v0.0.0-20210924111216-3b553750746e/go.mod h1:dOzMmMQFPH0ztBhLFNo/hFLHqck1tbhgL3aNi1XnOsI= git.sr.ht/~sircmpwn/core-go v0.0.0-20210924112641-378fedbc638f h1:JlJnutvLZHgNjwf5Lszrs7Slcjr1AVDUIV0Jm/PpRWg= git.sr.ht/~sircmpwn/core-go v0.0.0-20210924112641-378fedbc638f/go.mod h1:dOzMmMQFPH0ztBhLFNo/hFLHqck1tbhgL3aNi1XnOsI= +git.sr.ht/~sircmpwn/core-go v0.0.0-20211124081341-d5f650dadb54 h1:KvNXff9WkPKIB3D158fH/R0ELiwEQly2rBndxhJGa+0= +git.sr.ht/~sircmpwn/core-go v0.0.0-20211124081341-d5f650dadb54/go.mod h1:dOzMmMQFPH0ztBhLFNo/hFLHqck1tbhgL3aNi1XnOsI= git.sr.ht/~sircmpwn/dowork v0.0.0-20201013160733-35ca012e4dc8/go.mod h1:8neHEO3503w/rNtttnR0JFpQgM/GFhaafVwvkPsFIDw= git.sr.ht/~sircmpwn/dowork v0.0.0-20201121170652-c2a771442daf h1:wRE9o+wlpTSuq/ucFJsfbglAobfGPIgFdaTtZXrk8P0= git.sr.ht/~sircmpwn/dowork v0.0.0-20201121170652-c2a771442daf/go.mod h1:8neHEO3503w/rNtttnR0JFpQgM/GFhaafVwvkPsFIDw= diff --git a/api/graph/api/generated.go b/api/graph/api/generated.go index 86c31d9..a73ff20 100644 --- a/api/graph/api/generated.go +++ b/api/graph/api/generated.go @@ -1593,7 +1593,7 @@ type User implements Entity { location: String bio: String - userType: UserType! @internal + userType: UserType! @private suspensionNotice: String @internal sshKeys(cursor: Cursor): SSHKeyCursor! @access(scope: SSH_KEYS, kind: RO) @@ -7684,10 +7684,10 @@ func (ec *executionContext) _User_userType(ctx context.Context, field graphql.Co return obj.UserType(), nil } directive1 := func(ctx context.Context) (interface{}, error) { - if ec.directives.Internal == nil { - return nil, errors.New("directive internal is not implemented") + if ec.directives.Private == nil { + return nil, errors.New("directive private is not implemented") } - return ec.directives.Internal(ctx, obj, directive0) + return ec.directives.Private(ctx, obj, directive0) } tmp, err := directive1(rctx) diff --git a/api/graph/schema.graphqls b/api/graph/schema.graphqls index dc460c5..0fedb40 100644 --- a/api/graph/schema.graphqls +++ b/api/graph/schema.graphqls @@ -75,7 +75,7 @@ type User implements Entity { location: String bio: String - userType: UserType! @internal + userType: UserType! @private suspensionNotice: String @internal sshKeys(cursor: Cursor): SSHKeyCursor! @access(scope: SSH_KEYS, kind: RO) diff --git a/api/graph/schema.resolvers.go b/api/graph/schema.resolvers.go index df1b2bb..b4b5e39 100644 --- a/api/graph/schema.resolvers.go +++ b/api/graph/schema.resolvers.go @@ -70,10 +70,10 @@ func (r *mutationResolver) UpdateUser(ctx context.Context, input map[string]inte WithField("url"). And(url == nil || // Prevents nil dereference if Expect failed (url.Host != "" && (url.Scheme == "http" || - url.Scheme == "https" || - url.Scheme == "gopher" || - url.Scheme == "gemini" || - url.Scheme == "finger")), + url.Scheme == "https" || + url.Scheme == "gopher" || + url.Scheme == "gemini" || + url.Scheme == "finger")), "URL must have a host and a permitted scheme"). WithField("url") }) -- 2.34.2