diff --git a/server/constants/env.go b/server/constants/env.go index c766722..68131bf 100644 --- a/server/constants/env.go +++ b/server/constants/env.go @@ -9,8 +9,9 @@ import ( ) var ( - DB_TYPE = enum.Postgres - DB_URL = "postgresql://localhost:5432/postgres" + ENV = "" + DB_TYPE = "" + DB_URL = "" SMTP_HOST = "" SMTP_PORT = "" SENDER_EMAIL = "" @@ -18,6 +19,10 @@ var ( JWT_TYPE = "" JWT_SECRET = "" FRONTEND_URL = "" + PORT = "8080" + REDIS_URL = "" + IS_PROD = false + COOKIE_NAME = "" ) func init() { @@ -26,6 +31,9 @@ func init() { log.Println("Error loading .env file") } + ENV = os.Getenv("ENV") + DB_TYPE = os.Getenv("DB_TYPE") + DB_URL = os.Getenv("DB_URL") SMTP_HOST = os.Getenv("SMTP_HOST") SMTP_PORT = os.Getenv("SMTP_PORT") SENDER_EMAIL = os.Getenv("SENDER_EMAIL") @@ -33,4 +41,33 @@ func init() { JWT_SECRET = os.Getenv("JWT_SECRET") JWT_TYPE = os.Getenv("JWT_TYPE") FRONTEND_URL = os.Getenv("FRONTEND_URL") + PORT = os.Getenv("PORT") + REDIS_URL = os.Getenv("REDIS_URL") + COOKIE_NAME = os.Getenv("COOKIE_NAME") + + if ENV == "" { + ENV = "production" + } + + if ENV == "production" { + IS_PROD = true + } else { + IS_PROD = false + } + + if DB_TYPE == "" { + DB_TYPE = enum.Postgres.String() + } + + if DB_URL == "" { + DB_TYPE = "postgresql://localhost:5432/postgres" + } + + if JWT_TYPE == "" { + JWT_TYPE = "HS256" + } + + if COOKIE_NAME == "" { + COOKIE_NAME = "yauth" + } } diff --git a/server/db/db.go b/server/db/db.go index 21f81a2..4589dc6 100644 --- a/server/db/db.go +++ b/server/db/db.go @@ -36,13 +36,13 @@ func init() { TablePrefix: "yauth_", }, } - if constants.DB_TYPE == enum.Postgres { + if constants.DB_TYPE == enum.Postgres.String() { db, err = gorm.Open(postgres.Open(constants.DB_URL), ormConfig) } - if constants.DB_TYPE == enum.Mysql { + if constants.DB_TYPE == enum.Mysql.String() { db, err = gorm.Open(mysql.Open(constants.DB_URL), ormConfig) } - if constants.DB_TYPE == enum.Sqlite { + if constants.DB_TYPE == enum.Sqlite.String() { db, err = gorm.Open(sqlite.Open(constants.DB_URL), ormConfig) } diff --git a/server/db/user.go b/server/db/user.go index bc33236..ccd2ab0 100644 --- a/server/db/user.go +++ b/server/db/user.go @@ -18,11 +18,13 @@ type User struct { EmailVerifiedAt int64 CreatedAt int64 `gorm:"autoCreateTime"` UpdatedAt int64 `gorm:"autoUpdateTime"` + Image string + SignUpMethod string } func (user *User) BeforeSave(tx *gorm.DB) error { // Modify current operation through tx.Statement, e.g: - if pw, err := bcrypt.GenerateFromPassword([]byte(user.Password), 0); err == nil { + if pw, err := bcrypt.GenerateFromPassword([]byte(user.Password), bcrypt.DefaultCost); err == nil { tx.Statement.SetColumn("Password", pw) } @@ -31,7 +33,7 @@ func (user *User) BeforeSave(tx *gorm.DB) error { // AddUser function to add user func (mgr *manager) AddUser(user User) (User, error) { - result := mgr.db.Clauses(clause.OnConflict{DoNothing: true}).Create(&user) + result := mgr.db.Clauses(clause.OnConflict{UpdateAll: true, Columns: []clause.Column{{Name: "email"}}}).Create(&user) if result.Error != nil { log.Println(result.Error) return user, result.Error diff --git a/server/enum/signUpMethod.go b/server/enum/signUpMethod.go index b18fc20..acc8540 100644 --- a/server/enum/signUpMethod.go +++ b/server/enum/signUpMethod.go @@ -3,7 +3,7 @@ package enum type SignupMethod int const ( - Basic SignupMethod = iota + BasicAuth SignupMethod = iota MagicLink Google Github @@ -12,8 +12,8 @@ const ( func (d SignupMethod) String() string { return [...]string{ - "basic", - "magiclink", + "basic_auth", + "magic_link", "google", "github", "facebook", diff --git a/server/enum/tokenType.go b/server/enum/tokenType.go new file mode 100644 index 0000000..f97e1e2 --- /dev/null +++ b/server/enum/tokenType.go @@ -0,0 +1,15 @@ +package enum + +type TokenType int + +const ( + RefreshToken TokenType = iota + AccessToken +) + +func (d TokenType) String() string { + return [...]string{ + "refresh_token", + "access_token", + }[d] +} diff --git a/server/go.mod b/server/go.mod index 40341d4..de3bdde 100644 --- a/server/go.mod +++ b/server/go.mod @@ -4,13 +4,18 @@ go 1.16 require ( github.com/99designs/gqlgen v0.13.0 // indirect + github.com/gin-gonic/gin v1.7.2 // indirect + github.com/go-redis/redis/v8 v8.11.0 // indirect github.com/golang-jwt/jwt v3.2.1+incompatible // indirect github.com/jackc/pgproto3/v2 v2.1.0 // indirect github.com/joho/godotenv v1.3.0 // indirect github.com/mattn/go-sqlite3 v1.14.7 // indirect + github.com/rs/cors v1.8.0 // indirect github.com/vektah/gqlparser/v2 v2.1.0 // indirect golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e // indirect golang.org/x/text v0.3.6 // indirect + gopkg.in/go-playground/assert.v1 v1.2.1 // indirect + gopkg.in/go-playground/validator.v9 v9.29.1 // indirect gorm.io/driver/mysql v1.1.1 // indirect gorm.io/driver/postgres v1.1.0 // indirect gorm.io/driver/sqlite v1.1.4 // indirect diff --git a/server/go.sum b/server/go.sum index 47719ae..17d07b1 100644 --- a/server/go.sum +++ b/server/go.sum @@ -34,6 +34,7 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= @@ -51,6 +52,8 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= @@ -64,7 +67,13 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do= +github.com/gin-gonic/gin v1.7.2 h1:Tg03T9yM2xa8j6I3Z3oqLaQRSmKvxPd6g/2HJ6zICFA= +github.com/gin-gonic/gin v1.7.2/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= github.com/go-chi/chi v3.3.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= @@ -72,6 +81,17 @@ github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgO github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM= +github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= +github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= +github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= +github.com/go-redis/redis/v8 v8.11.0 h1:O1Td0mQ8UFChQ3N9zFQqo6kTU2cJ+/it88gDB+zg0wo= +github.com/go-redis/redis/v8 v8.11.0/go.mod h1:DLomh7y2e3ggQXQLd1YgmvIfecPJoFl7WU5SOQ/r06M= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= @@ -91,12 +111,23 @@ github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -202,6 +233,8 @@ github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22 github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= @@ -213,6 +246,9 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= +github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= @@ -234,6 +270,7 @@ github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= +github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-sqlite3 v1.14.5/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI= @@ -252,8 +289,10 @@ github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:F github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= @@ -263,12 +302,18 @@ github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzE github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.15.0/go.mod h1:hF8qUzuuC8DJGygJH3726JnCZX4MYbRB8yFfISqnKUg= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= @@ -310,6 +355,8 @@ github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqn github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/rs/cors v1.8.0 h1:P2KMzcFwrPoSjkF1WLRPsp3UMLyql8L4v9hQpVeK5so= +github.com/rs/cors v1.8.0/go.mod h1:EBwu+T5AvHOcXwvZIkQFjUN6s8Czyqw12GL/Y0tUyRM= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= @@ -347,6 +394,10 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= +github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= +github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= +github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= @@ -357,6 +408,7 @@ github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUd github.com/vektah/gqlparser/v2 v2.1.0 h1:uiKJ+T5HMGGQM2kRKQ8Pxw8+Zq9qhhZhz/lieYvCMns= github.com/vektah/gqlparser/v2 v2.1.0/go.mod h1:SyUiHgLATUR8BiYURfTirrTcGpcE+4XkV2se04Px1Ms= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= @@ -384,6 +436,7 @@ golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e h1:gsTQYXdTw2Gq7RBsWvlQ91b+aEQ6bXFUngBGuR8sPpI= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= @@ -395,6 +448,8 @@ golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -411,6 +466,9 @@ golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -420,6 +478,7 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -437,10 +496,17 @@ golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -466,14 +532,19 @@ golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgw golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589 h1:rjUrONFu4kLchcZTfp3/96bR8bW8dIa8uz3cR5n0cgM= golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e h1:4nW4NLDYnU28ojHaHO8OVxFHk/aQ33U01a9cjED+pzE= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -492,6 +563,13 @@ google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -500,6 +578,8 @@ gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qS gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= +gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= +gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= @@ -509,6 +589,10 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gorm.io/driver/mysql v1.1.1 h1:yr1bpyqiwuSPJ4aGGUX9nu46RHXlF8RASQVb1QQNcvo= gorm.io/driver/mysql v1.1.1/go.mod h1:KdrTanmfLPPyAOeYGyG+UpDys7/7eeWT1zCq+oekYnU= gorm.io/driver/postgres v1.1.0 h1:afBljg7PtJ5lA6YUWluV2+xovIPhS+YiInuL3kUjrbk= diff --git a/server/gqlgen.yml b/server/gqlgen.yml index fe371eb..1e2d628 100644 --- a/server/gqlgen.yml +++ b/server/gqlgen.yml @@ -45,6 +45,7 @@ autobind: models: ID: model: + # - github.com/99designs/gqlgen/graphql.IntID # An go integer - github.com/99designs/gqlgen/graphql.ID - github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int64 diff --git a/server/graph/generated/generated.go b/server/graph/generated/generated.go index 065d406..b452c46 100644 --- a/server/graph/generated/generated.go +++ b/server/graph/generated/generated.go @@ -43,21 +43,9 @@ type DirectiveRoot struct { } type ComplexityRoot struct { - BasicAuthLoginResponse struct { - Errors func(childComplexity int) int - Message func(childComplexity int) int - RefreshToken func(childComplexity int) int - StatusCode func(childComplexity int) int - Success func(childComplexity int) int - User func(childComplexity int) int - } - BasicAuthSignupResponse struct { - Errors func(childComplexity int) int - Message func(childComplexity int) int - StatusCode func(childComplexity int) int - Success func(childComplexity int) int - User func(childComplexity int) int + Message func(childComplexity int) int + User func(childComplexity int) int } Error struct { @@ -65,21 +53,25 @@ type ComplexityRoot struct { Reason func(childComplexity int) int } + LoginResponse struct { + AccessToken func(childComplexity int) int + Message func(childComplexity int) int + User func(childComplexity int) int + } + Mutation struct { - BasicAuthLogin func(childComplexity int, params model.BasicAuthLoginInput) int BasicAuthSignUp func(childComplexity int, params model.BasicAuthSignupInput) int + Login func(childComplexity int, params model.LoginInput) int VerifySignupToken func(childComplexity int, params model.VerifySignupTokenInput) int } Query struct { - Users func(childComplexity int) int + UpdateToken func(childComplexity int) int + Users func(childComplexity int) int } Response struct { - Errors func(childComplexity int) int - Message func(childComplexity int) int - StatusCode func(childComplexity int) int - Success func(childComplexity int) int + Message func(childComplexity int) int } User struct { @@ -109,10 +101,11 @@ type ComplexityRoot struct { type MutationResolver interface { VerifySignupToken(ctx context.Context, params model.VerifySignupTokenInput) (*model.Response, error) BasicAuthSignUp(ctx context.Context, params model.BasicAuthSignupInput) (*model.BasicAuthSignupResponse, error) - BasicAuthLogin(ctx context.Context, params model.BasicAuthLoginInput) (*model.BasicAuthLoginResponse, error) + Login(ctx context.Context, params model.LoginInput) (*model.LoginResponse, error) } type QueryResolver interface { Users(ctx context.Context) ([]*model.User, error) + UpdateToken(ctx context.Context) (*model.LoginResponse, error) } type executableSchema struct { @@ -130,55 +123,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { - case "BasicAuthLoginResponse.errors": - if e.complexity.BasicAuthLoginResponse.Errors == nil { - break - } - - return e.complexity.BasicAuthLoginResponse.Errors(childComplexity), true - - case "BasicAuthLoginResponse.message": - if e.complexity.BasicAuthLoginResponse.Message == nil { - break - } - - return e.complexity.BasicAuthLoginResponse.Message(childComplexity), true - - case "BasicAuthLoginResponse.refreshToken": - if e.complexity.BasicAuthLoginResponse.RefreshToken == nil { - break - } - - return e.complexity.BasicAuthLoginResponse.RefreshToken(childComplexity), true - - case "BasicAuthLoginResponse.statusCode": - if e.complexity.BasicAuthLoginResponse.StatusCode == nil { - break - } - - return e.complexity.BasicAuthLoginResponse.StatusCode(childComplexity), true - - case "BasicAuthLoginResponse.success": - if e.complexity.BasicAuthLoginResponse.Success == nil { - break - } - - return e.complexity.BasicAuthLoginResponse.Success(childComplexity), true - - case "BasicAuthLoginResponse.user": - if e.complexity.BasicAuthLoginResponse.User == nil { - break - } - - return e.complexity.BasicAuthLoginResponse.User(childComplexity), true - - case "BasicAuthSignupResponse.errors": - if e.complexity.BasicAuthSignupResponse.Errors == nil { - break - } - - return e.complexity.BasicAuthSignupResponse.Errors(childComplexity), true - case "BasicAuthSignupResponse.message": if e.complexity.BasicAuthSignupResponse.Message == nil { break @@ -186,20 +130,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.BasicAuthSignupResponse.Message(childComplexity), true - case "BasicAuthSignupResponse.statusCode": - if e.complexity.BasicAuthSignupResponse.StatusCode == nil { - break - } - - return e.complexity.BasicAuthSignupResponse.StatusCode(childComplexity), true - - case "BasicAuthSignupResponse.success": - if e.complexity.BasicAuthSignupResponse.Success == nil { - break - } - - return e.complexity.BasicAuthSignupResponse.Success(childComplexity), true - case "BasicAuthSignupResponse.user": if e.complexity.BasicAuthSignupResponse.User == nil { break @@ -221,17 +151,26 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Error.Reason(childComplexity), true - case "Mutation.basicAuthLogin": - if e.complexity.Mutation.BasicAuthLogin == nil { + case "LoginResponse.accessToken": + if e.complexity.LoginResponse.AccessToken == nil { break } - args, err := ec.field_Mutation_basicAuthLogin_args(context.TODO(), rawArgs) - if err != nil { - return 0, false + return e.complexity.LoginResponse.AccessToken(childComplexity), true + + case "LoginResponse.message": + if e.complexity.LoginResponse.Message == nil { + break } - return e.complexity.Mutation.BasicAuthLogin(childComplexity, args["params"].(model.BasicAuthLoginInput)), true + return e.complexity.LoginResponse.Message(childComplexity), true + + case "LoginResponse.user": + if e.complexity.LoginResponse.User == nil { + break + } + + return e.complexity.LoginResponse.User(childComplexity), true case "Mutation.basicAuthSignUp": if e.complexity.Mutation.BasicAuthSignUp == nil { @@ -245,6 +184,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.BasicAuthSignUp(childComplexity, args["params"].(model.BasicAuthSignupInput)), true + case "Mutation.login": + if e.complexity.Mutation.Login == nil { + break + } + + args, err := ec.field_Mutation_login_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.Login(childComplexity, args["params"].(model.LoginInput)), true + case "Mutation.verifySignupToken": if e.complexity.Mutation.VerifySignupToken == nil { break @@ -257,6 +208,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.VerifySignupToken(childComplexity, args["params"].(model.VerifySignupTokenInput)), true + case "Query.updateToken": + if e.complexity.Query.UpdateToken == nil { + break + } + + return e.complexity.Query.UpdateToken(childComplexity), true + case "Query.users": if e.complexity.Query.Users == nil { break @@ -264,13 +222,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Users(childComplexity), true - case "Response.errors": - if e.complexity.Response.Errors == nil { - break - } - - return e.complexity.Response.Errors(childComplexity), true - case "Response.message": if e.complexity.Response.Message == nil { break @@ -278,20 +229,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Response.Message(childComplexity), true - case "Response.statusCode": - if e.complexity.Response.StatusCode == nil { - break - } - - return e.complexity.Response.StatusCode(childComplexity), true - - case "Response.success": - if e.complexity.Response.Success == nil { - break - } - - return e.complexity.Response.Success(childComplexity), true - case "User.createdAt": if e.complexity.User.CreatedAt == nil { break @@ -509,33 +446,20 @@ type Error { } type Response { - success: Boolean! message: String! - errors: [Error!] - statusCode: Int! } -type BasicAuthLoginResponse { - success: Boolean! +type LoginResponse { message: String! - errors: [Error!] - statusCode: Int! - refreshToken: String + accessToken: String user: User } type BasicAuthSignupResponse { - success: Boolean! message: String! - errors: [Error!] - statusCode: Int! user: User } -type Query { - users: [User!]! -} - input BasicAuthSignupInput { firstName: String lastName: String @@ -545,7 +469,7 @@ input BasicAuthSignupInput { image: String } -input BasicAuthLoginInput { +input LoginInput { email: String! password: String! } @@ -557,7 +481,12 @@ input VerifySignupTokenInput { type Mutation { verifySignupToken(params: VerifySignupTokenInput!): Response! basicAuthSignUp(params: BasicAuthSignupInput!): BasicAuthSignupResponse! - basicAuthLogin(params: BasicAuthLoginInput!): BasicAuthLoginResponse! + login(params: LoginInput!): LoginResponse! +} + +type Query { + users: [User!]! + updateToken: LoginResponse } `, BuiltIn: false}, } @@ -567,13 +496,13 @@ var parsedSchema = gqlparser.MustLoadSchema(sources...) // region ***************************** args.gotpl ***************************** -func (ec *executionContext) field_Mutation_basicAuthLogin_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Mutation_basicAuthSignUp_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 model.BasicAuthLoginInput + var arg0 model.BasicAuthSignupInput if tmp, ok := rawArgs["params"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params")) - arg0, err = ec.unmarshalNBasicAuthLoginInput2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐBasicAuthLoginInput(ctx, tmp) + arg0, err = ec.unmarshalNBasicAuthSignupInput2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐBasicAuthSignupInput(ctx, tmp) if err != nil { return nil, err } @@ -582,13 +511,13 @@ func (ec *executionContext) field_Mutation_basicAuthLogin_args(ctx context.Conte return args, nil } -func (ec *executionContext) field_Mutation_basicAuthSignUp_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Mutation_login_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 model.BasicAuthSignupInput + var arg0 model.LoginInput if tmp, ok := rawArgs["params"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params")) - arg0, err = ec.unmarshalNBasicAuthSignupInput2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐBasicAuthSignupInput(ctx, tmp) + arg0, err = ec.unmarshalNLoginInput2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐLoginInput(ctx, tmp) if err != nil { return nil, err } @@ -665,242 +594,6 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region **************************** field.gotpl ***************************** -func (ec *executionContext) _BasicAuthLoginResponse_success(ctx context.Context, field graphql.CollectedField, obj *model.BasicAuthLoginResponse) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "BasicAuthLoginResponse", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Success, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _BasicAuthLoginResponse_message(ctx context.Context, field graphql.CollectedField, obj *model.BasicAuthLoginResponse) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "BasicAuthLoginResponse", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Message, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) _BasicAuthLoginResponse_errors(ctx context.Context, field graphql.CollectedField, obj *model.BasicAuthLoginResponse) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "BasicAuthLoginResponse", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Errors, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*model.Error) - fc.Result = res - return ec.marshalOError2ᚕᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐErrorᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) _BasicAuthLoginResponse_statusCode(ctx context.Context, field graphql.CollectedField, obj *model.BasicAuthLoginResponse) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "BasicAuthLoginResponse", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.StatusCode, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) -} - -func (ec *executionContext) _BasicAuthLoginResponse_refreshToken(ctx context.Context, field graphql.CollectedField, obj *model.BasicAuthLoginResponse) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "BasicAuthLoginResponse", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.RefreshToken, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) _BasicAuthLoginResponse_user(ctx context.Context, field graphql.CollectedField, obj *model.BasicAuthLoginResponse) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "BasicAuthLoginResponse", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.User, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*model.User) - fc.Result = res - return ec.marshalOUser2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) -} - -func (ec *executionContext) _BasicAuthSignupResponse_success(ctx context.Context, field graphql.CollectedField, obj *model.BasicAuthSignupResponse) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "BasicAuthSignupResponse", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Success, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - func (ec *executionContext) _BasicAuthSignupResponse_message(ctx context.Context, field graphql.CollectedField, obj *model.BasicAuthSignupResponse) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -936,73 +629,6 @@ func (ec *executionContext) _BasicAuthSignupResponse_message(ctx context.Context return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _BasicAuthSignupResponse_errors(ctx context.Context, field graphql.CollectedField, obj *model.BasicAuthSignupResponse) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "BasicAuthSignupResponse", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Errors, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*model.Error) - fc.Result = res - return ec.marshalOError2ᚕᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐErrorᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) _BasicAuthSignupResponse_statusCode(ctx context.Context, field graphql.CollectedField, obj *model.BasicAuthSignupResponse) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "BasicAuthSignupResponse", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.StatusCode, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) -} - func (ec *executionContext) _BasicAuthSignupResponse_user(ctx context.Context, field graphql.CollectedField, obj *model.BasicAuthSignupResponse) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -1105,6 +731,105 @@ func (ec *executionContext) _Error_reason(ctx context.Context, field graphql.Col return ec.marshalNString2string(ctx, field.Selections, res) } +func (ec *executionContext) _LoginResponse_message(ctx context.Context, field graphql.CollectedField, obj *model.LoginResponse) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "LoginResponse", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Message, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) _LoginResponse_accessToken(ctx context.Context, field graphql.CollectedField, obj *model.LoginResponse) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "LoginResponse", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.AccessToken, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _LoginResponse_user(ctx context.Context, field graphql.CollectedField, obj *model.LoginResponse) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "LoginResponse", + Field: field, + Args: nil, + IsMethod: false, + IsResolver: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.User, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.User) + fc.Result = res + return ec.marshalOUser2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) +} + func (ec *executionContext) _Mutation_verifySignupToken(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -1189,7 +914,7 @@ func (ec *executionContext) _Mutation_basicAuthSignUp(ctx context.Context, field return ec.marshalNBasicAuthSignupResponse2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐBasicAuthSignupResponse(ctx, field.Selections, res) } -func (ec *executionContext) _Mutation_basicAuthLogin(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_login(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -1206,7 +931,7 @@ func (ec *executionContext) _Mutation_basicAuthLogin(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_basicAuthLogin_args(ctx, rawArgs) + args, err := ec.field_Mutation_login_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -1214,7 +939,7 @@ func (ec *executionContext) _Mutation_basicAuthLogin(ctx context.Context, field fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().BasicAuthLogin(rctx, args["params"].(model.BasicAuthLoginInput)) + return ec.resolvers.Mutation().Login(rctx, args["params"].(model.LoginInput)) }) if err != nil { ec.Error(ctx, err) @@ -1226,9 +951,9 @@ func (ec *executionContext) _Mutation_basicAuthLogin(ctx context.Context, field } return graphql.Null } - res := resTmp.(*model.BasicAuthLoginResponse) + res := resTmp.(*model.LoginResponse) fc.Result = res - return ec.marshalNBasicAuthLoginResponse2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐBasicAuthLoginResponse(ctx, field.Selections, res) + return ec.marshalNLoginResponse2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐLoginResponse(ctx, field.Selections, res) } func (ec *executionContext) _Query_users(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { @@ -1266,6 +991,38 @@ func (ec *executionContext) _Query_users(ctx context.Context, field graphql.Coll return ec.marshalNUser2ᚕᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐUserᚄ(ctx, field.Selections, res) } +func (ec *executionContext) _Query_updateToken(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, + IsResolver: true, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().UpdateToken(rctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.LoginResponse) + fc.Result = res + return ec.marshalOLoginResponse2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐLoginResponse(ctx, field.Selections, res) +} + func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -1337,41 +1094,6 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -func (ec *executionContext) _Response_success(ctx context.Context, field graphql.CollectedField, obj *model.Response) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Response", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Success, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - func (ec *executionContext) _Response_message(ctx context.Context, field graphql.CollectedField, obj *model.Response) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -1407,73 +1129,6 @@ func (ec *executionContext) _Response_message(ctx context.Context, field graphql return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Response_errors(ctx context.Context, field graphql.CollectedField, obj *model.Response) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Response", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Errors, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*model.Error) - fc.Result = res - return ec.marshalOError2ᚕᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐErrorᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) _Response_statusCode(ctx context.Context, field graphql.CollectedField, obj *model.Response) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Response", - Field: field, - Args: nil, - IsMethod: false, - IsResolver: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.StatusCode, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) -} - func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -3117,34 +2772,6 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func (ec *executionContext) unmarshalInputBasicAuthLoginInput(ctx context.Context, obj interface{}) (model.BasicAuthLoginInput, error) { - var it model.BasicAuthLoginInput - var asMap = obj.(map[string]interface{}) - - for k, v := range asMap { - switch k { - case "email": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email")) - it.Email, err = ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - case "password": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("password")) - it.Password, err = ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - func (ec *executionContext) unmarshalInputBasicAuthSignupInput(ctx context.Context, obj interface{}) (model.BasicAuthSignupInput, error) { var it model.BasicAuthSignupInput var asMap = obj.(map[string]interface{}) @@ -3205,6 +2832,34 @@ func (ec *executionContext) unmarshalInputBasicAuthSignupInput(ctx context.Conte return it, nil } +func (ec *executionContext) unmarshalInputLoginInput(ctx context.Context, obj interface{}) (model.LoginInput, error) { + var it model.LoginInput + var asMap = obj.(map[string]interface{}) + + for k, v := range asMap { + switch k { + case "email": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email")) + it.Email, err = ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + case "password": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("password")) + it.Password, err = ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + func (ec *executionContext) unmarshalInputVerifySignupTokenInput(ctx context.Context, obj interface{}) (model.VerifySignupTokenInput, error) { var it model.VerifySignupTokenInput var asMap = obj.(map[string]interface{}) @@ -3233,49 +2888,6 @@ func (ec *executionContext) unmarshalInputVerifySignupTokenInput(ctx context.Con // region **************************** object.gotpl **************************** -var basicAuthLoginResponseImplementors = []string{"BasicAuthLoginResponse"} - -func (ec *executionContext) _BasicAuthLoginResponse(ctx context.Context, sel ast.SelectionSet, obj *model.BasicAuthLoginResponse) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, basicAuthLoginResponseImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("BasicAuthLoginResponse") - case "success": - out.Values[i] = ec._BasicAuthLoginResponse_success(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "message": - out.Values[i] = ec._BasicAuthLoginResponse_message(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "errors": - out.Values[i] = ec._BasicAuthLoginResponse_errors(ctx, field, obj) - case "statusCode": - out.Values[i] = ec._BasicAuthLoginResponse_statusCode(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "refreshToken": - out.Values[i] = ec._BasicAuthLoginResponse_refreshToken(ctx, field, obj) - case "user": - out.Values[i] = ec._BasicAuthLoginResponse_user(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - var basicAuthSignupResponseImplementors = []string{"BasicAuthSignupResponse"} func (ec *executionContext) _BasicAuthSignupResponse(ctx context.Context, sel ast.SelectionSet, obj *model.BasicAuthSignupResponse) graphql.Marshaler { @@ -3287,23 +2899,11 @@ func (ec *executionContext) _BasicAuthSignupResponse(ctx context.Context, sel as switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("BasicAuthSignupResponse") - case "success": - out.Values[i] = ec._BasicAuthSignupResponse_success(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } case "message": out.Values[i] = ec._BasicAuthSignupResponse_message(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } - case "errors": - out.Values[i] = ec._BasicAuthSignupResponse_errors(ctx, field, obj) - case "statusCode": - out.Values[i] = ec._BasicAuthSignupResponse_statusCode(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } case "user": out.Values[i] = ec._BasicAuthSignupResponse_user(ctx, field, obj) default: @@ -3349,6 +2949,37 @@ func (ec *executionContext) _Error(ctx context.Context, sel ast.SelectionSet, ob return out } +var loginResponseImplementors = []string{"LoginResponse"} + +func (ec *executionContext) _LoginResponse(ctx context.Context, sel ast.SelectionSet, obj *model.LoginResponse) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, loginResponseImplementors) + + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("LoginResponse") + case "message": + out.Values[i] = ec._LoginResponse_message(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + case "accessToken": + out.Values[i] = ec._LoginResponse_accessToken(ctx, field, obj) + case "user": + out.Values[i] = ec._LoginResponse_user(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + var mutationImplementors = []string{"Mutation"} func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { @@ -3374,8 +3005,8 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { invalids++ } - case "basicAuthLogin": - out.Values[i] = ec._Mutation_basicAuthLogin(ctx, field) + case "login": + out.Values[i] = ec._Mutation_login(ctx, field) if out.Values[i] == graphql.Null { invalids++ } @@ -3419,6 +3050,17 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } return res }) + case "updateToken": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_updateToken(ctx, field) + return res + }) case "__type": out.Values[i] = ec._Query___type(ctx, field) case "__schema": @@ -3445,23 +3087,11 @@ func (ec *executionContext) _Response(ctx context.Context, sel ast.SelectionSet, switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("Response") - case "success": - out.Values[i] = ec._Response_success(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } case "message": out.Values[i] = ec._Response_message(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } - case "errors": - out.Values[i] = ec._Response_errors(ctx, field, obj) - case "statusCode": - out.Values[i] = ec._Response_statusCode(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -3808,25 +3438,6 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) unmarshalNBasicAuthLoginInput2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐBasicAuthLoginInput(ctx context.Context, v interface{}) (model.BasicAuthLoginInput, error) { - res, err := ec.unmarshalInputBasicAuthLoginInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNBasicAuthLoginResponse2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐBasicAuthLoginResponse(ctx context.Context, sel ast.SelectionSet, v model.BasicAuthLoginResponse) graphql.Marshaler { - return ec._BasicAuthLoginResponse(ctx, sel, &v) -} - -func (ec *executionContext) marshalNBasicAuthLoginResponse2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐBasicAuthLoginResponse(ctx context.Context, sel ast.SelectionSet, v *model.BasicAuthLoginResponse) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._BasicAuthLoginResponse(ctx, sel, v) -} - func (ec *executionContext) unmarshalNBasicAuthSignupInput2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐBasicAuthSignupInput(ctx context.Context, v interface{}) (model.BasicAuthSignupInput, error) { res, err := ec.unmarshalInputBasicAuthSignupInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -3861,16 +3472,6 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se return res } -func (ec *executionContext) marshalNError2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐError(ctx context.Context, sel ast.SelectionSet, v *model.Error) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._Error(ctx, sel, v) -} - func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { res, err := graphql.UnmarshalID(v) return res, graphql.ErrorOnPath(ctx, err) @@ -3886,19 +3487,23 @@ func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.Selec return res } -func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) { - res, err := graphql.UnmarshalInt(v) +func (ec *executionContext) unmarshalNLoginInput2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐLoginInput(ctx context.Context, v interface{}) (model.LoginInput, error) { + res, err := ec.unmarshalInputLoginInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { - res := graphql.MarshalInt(v) - if res == graphql.Null { +func (ec *executionContext) marshalNLoginResponse2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐLoginResponse(ctx context.Context, sel ast.SelectionSet, v model.LoginResponse) graphql.Marshaler { + return ec._LoginResponse(ctx, sel, &v) +} + +func (ec *executionContext) marshalNLoginResponse2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐLoginResponse(ctx context.Context, sel ast.SelectionSet, v *model.LoginResponse) graphql.Marshaler { + if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "must not be null") } + return graphql.Null } - return res + return ec._LoginResponse(ctx, sel, v) } func (ec *executionContext) marshalNResponse2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐResponse(ctx context.Context, sel ast.SelectionSet, v model.Response) graphql.Marshaler { @@ -4235,46 +3840,6 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast return graphql.MarshalBoolean(*v) } -func (ec *executionContext) marshalOError2ᚕᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐErrorᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.Error) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNError2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐError(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - return ret -} - func (ec *executionContext) unmarshalOInt642ᚖint64(ctx context.Context, v interface{}) (*int64, error) { if v == nil { return nil, nil @@ -4290,6 +3855,13 @@ func (ec *executionContext) marshalOInt642ᚖint64(ctx context.Context, sel ast. return graphql.MarshalInt64(*v) } +func (ec *executionContext) marshalOLoginResponse2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐLoginResponse(ctx context.Context, sel ast.SelectionSet, v *model.LoginResponse) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._LoginResponse(ctx, sel, v) +} + func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { res, err := graphql.UnmarshalString(v) return res, graphql.ErrorOnPath(ctx, err) diff --git a/server/graph/model/models_gen.go b/server/graph/model/models_gen.go index d0e317b..032d473 100644 --- a/server/graph/model/models_gen.go +++ b/server/graph/model/models_gen.go @@ -2,20 +2,6 @@ package model -type BasicAuthLoginInput struct { - Email string `json:"email"` - Password string `json:"password"` -} - -type BasicAuthLoginResponse struct { - Success bool `json:"success"` - Message string `json:"message"` - Errors []*Error `json:"errors"` - StatusCode int `json:"statusCode"` - RefreshToken *string `json:"refreshToken"` - User *User `json:"user"` -} - type BasicAuthSignupInput struct { FirstName *string `json:"firstName"` LastName *string `json:"lastName"` @@ -26,11 +12,8 @@ type BasicAuthSignupInput struct { } type BasicAuthSignupResponse struct { - Success bool `json:"success"` - Message string `json:"message"` - Errors []*Error `json:"errors"` - StatusCode int `json:"statusCode"` - User *User `json:"user"` + Message string `json:"message"` + User *User `json:"user"` } type Error struct { @@ -38,11 +21,19 @@ type Error struct { Reason string `json:"reason"` } +type LoginInput struct { + Email string `json:"email"` + Password string `json:"password"` +} + +type LoginResponse struct { + Message string `json:"message"` + AccessToken *string `json:"accessToken"` + User *User `json:"user"` +} + type Response struct { - Success bool `json:"success"` - Message string `json:"message"` - Errors []*Error `json:"errors"` - StatusCode int `json:"statusCode"` + Message string `json:"message"` } type User struct { diff --git a/server/graph/schema.graphqls b/server/graph/schema.graphqls index 7e724c0..1061963 100644 --- a/server/graph/schema.graphqls +++ b/server/graph/schema.graphqls @@ -32,33 +32,20 @@ type Error { } type Response { - success: Boolean! message: String! - errors: [Error!] - statusCode: Int! } -type BasicAuthLoginResponse { - success: Boolean! +type LoginResponse { message: String! - errors: [Error!] - statusCode: Int! - refreshToken: String + accessToken: String user: User } type BasicAuthSignupResponse { - success: Boolean! message: String! - errors: [Error!] - statusCode: Int! user: User } -type Query { - users: [User!]! -} - input BasicAuthSignupInput { firstName: String lastName: String @@ -68,7 +55,7 @@ input BasicAuthSignupInput { image: String } -input BasicAuthLoginInput { +input LoginInput { email: String! password: String! } @@ -80,5 +67,10 @@ input VerifySignupTokenInput { type Mutation { verifySignupToken(params: VerifySignupTokenInput!): Response! basicAuthSignUp(params: BasicAuthSignupInput!): BasicAuthSignupResponse! - basicAuthLogin(params: BasicAuthLoginInput!): BasicAuthLoginResponse! + login(params: LoginInput!): LoginResponse! +} + +type Query { + users: [User!]! + updateToken: LoginResponse } diff --git a/server/graph/schema.resolvers.go b/server/graph/schema.resolvers.go index e8f2954..bbdd028 100644 --- a/server/graph/schema.resolvers.go +++ b/server/graph/schema.resolvers.go @@ -5,15 +5,19 @@ package graph import ( "context" + "errors" "fmt" "log" "strings" "time" "github.com/yauthdev/yauth/server/db" + "github.com/yauthdev/yauth/server/enum" "github.com/yauthdev/yauth/server/graph/generated" "github.com/yauthdev/yauth/server/graph/model" + "github.com/yauthdev/yauth/server/session" "github.com/yauthdev/yauth/server/utils" + "golang.org/x/crypto/bcrypt" ) func (r *mutationResolver) VerifySignupToken(ctx context.Context, params model.VerifySignupTokenInput) (*model.Response, error) { @@ -21,73 +25,36 @@ func (r *mutationResolver) VerifySignupToken(ctx context.Context, params model.V var res *model.Response _, err := db.Mgr.GetVerificationByToken(params.Token) if err != nil { - res = &model.Response{ - Success: false, - Message: `Invalid token`, - StatusCode: 400, - Errors: []*model.Error{&model.Error{ - Message: `Invalid token`, - Reason: `invalid token`, - }}, - } - } else { - - // verify if token exists in db - claim, err := utils.VerifyVerificationToken(params.Token) - if err != nil { - res = &model.Response{ - Success: false, - Message: `Invalid token`, - StatusCode: 400, - Errors: []*model.Error{&model.Error{ - Message: `Invalid token`, - Reason: `invalid token`, - }}, - } - } else { - res = &model.Response{ - Success: true, - Message: `Email verified successfully. Login to access the system.`, - StatusCode: 200, - } - - // update email_verified_at in users table - db.Mgr.UpdateVerificationTime(time.Now().Unix(), claim.Email) - // delete from verification table - db.Mgr.DeleteToken(claim.Email) - } - + return res, errors.New(`Invalid token`) } + // verify if token exists in db + claim, err := utils.VerifyVerificationToken(params.Token) + if err != nil { + return res, errors.New(`Invalid token`) + } + res = &model.Response{ + Message: `Email verified successfully. Login to access the system.`, + } + + // update email_verified_at in users table + db.Mgr.UpdateVerificationTime(time.Now().Unix(), claim.Email) + // delete from verification table + db.Mgr.DeleteToken(claim.Email) + return res, nil } func (r *mutationResolver) BasicAuthSignUp(ctx context.Context, params model.BasicAuthSignupInput) (*model.BasicAuthSignupResponse, error) { var res *model.BasicAuthSignupResponse if params.CofirmPassword != params.Password { - res = &model.BasicAuthSignupResponse{ - Success: false, - Message: `Passowrd and Confirm Password does not match`, - StatusCode: 400, - Errors: []*model.Error{&model.Error{ - Message: `Passowrd and Confirm Password does not match`, - Reason: `password and confirm_password fields should match`, - }}, - } + return res, errors.New(`Passowrd and Confirm Password does not match`) } params.Email = strings.ToLower(params.Email) if !utils.IsValidEmail(params.Email) { - res = &model.BasicAuthSignupResponse{ - Success: false, - Message: `Invalid email address`, - StatusCode: 400, - Errors: []*model.Error{&model.Error{ - Message: `Invalid email address`, - Reason: `invalid email address`, - }}, - } + return res, errors.New(`Invalid email address`) } // find user with email @@ -98,64 +65,107 @@ func (r *mutationResolver) BasicAuthSignUp(ctx context.Context, params model.Bas if existingUser.EmailVerifiedAt > 0 { // email is verified - res = &model.BasicAuthSignupResponse{ - Success: false, - Message: `You have already signed up. Please login`, - StatusCode: 400, - Errors: []*model.Error{&model.Error{ - Message: `Already signed up`, - Reason: `already signed up`, - }}, - } - } else { - user := db.User{ - Email: params.Email, - Password: params.Password, - } + return res, errors.New(`You have already signed up. Please login`) + } + user := db.User{ + Email: params.Email, + Password: params.Password, + } - if params.FirstName != nil { - user.FirstName = *params.FirstName - } + if params.FirstName != nil { + user.FirstName = *params.FirstName + } - if params.LastName != nil { - user.LastName = *params.LastName - } + if params.LastName != nil { + user.LastName = *params.LastName + } - _, err = db.Mgr.AddUser(user) - if err != nil { - return res, err - } + user.SignUpMethod = enum.BasicAuth.String() + _, err = db.Mgr.AddUser(user) + if err != nil { + return res, err + } - // insert verification request - verificationType := "BASIC_AUTH_SIGNUP" - token, err := utils.CreateVerificationToken(params.Email, verificationType) - if err != nil { - log.Println(`Error generating token`, err) - } - db.Mgr.AddVerification(db.Verification{ - Token: token, - Identifier: verificationType, - ExpiresAt: time.Now().Add(time.Minute * 30).Unix(), - Email: params.Email, - }) + // insert verification request + verificationType := enum.BasicAuth.String() + token, err := utils.CreateVerificationToken(params.Email, verificationType) + if err != nil { + log.Println(`Error generating token`, err) + } + db.Mgr.AddVerification(db.Verification{ + Token: token, + Identifier: verificationType, + ExpiresAt: time.Now().Add(time.Minute * 30).Unix(), + Email: params.Email, + }) - // exec it as go routin so that we can reduce the api latency - go func() { - utils.SendVerificationMail(params.Email, token) - }() + // exec it as go routin so that we can reduce the api latency + go func() { + utils.SendVerificationMail(params.Email, token) + }() - res = &model.BasicAuthSignupResponse{ - Success: true, - Message: `Verification email sent successfully. Please check your inbox`, - StatusCode: 200, - } + res = &model.BasicAuthSignupResponse{ + Message: `Verification email sent successfully. Please check your inbox`, } return res, nil } -func (r *mutationResolver) BasicAuthLogin(ctx context.Context, params model.BasicAuthLoginInput) (*model.BasicAuthLoginResponse, error) { - panic(fmt.Errorf("not implemented")) +func (r *mutationResolver) Login(ctx context.Context, params model.LoginInput) (*model.LoginResponse, error) { + gc, err := utils.GinContextFromContext(ctx) + var res *model.LoginResponse + if err != nil { + return res, err + } + + params.Email = strings.ToLower(params.Email) + user, err := db.Mgr.GetUserByEmail(params.Email) + if err != nil { + return res, errors.New(`User with this email not found`) + } + + if user.SignUpMethod != enum.BasicAuth.String() { + return res, errors.New(`User has not signed up email & password`) + } + + if user.EmailVerifiedAt <= 0 { + return res, errors.New(`Email not verified`) + } + // match password + err = bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(params.Password)) + if err != nil { + return res, errors.New(`Invalid Password`) + } + userIdStr := fmt.Sprintf("%d", user.ID) + log.Println("session object init -> ", session.GetToken(userIdStr)) + refreshToken, _ := utils.CreateAuthToken(utils.UserAuthInfo{ + ID: userIdStr, + Email: user.Email, + }, enum.RefreshToken) + + accessToken, _ := utils.CreateAuthToken(utils.UserAuthInfo{ + ID: userIdStr, + Email: user.Email, + }, enum.AccessToken) + + session.SetToken(userIdStr, refreshToken) + log.Println("session object -> ", session.GetToken(userIdStr)) + + res = &model.LoginResponse{ + Message: `Logged in successfully`, + AccessToken: &accessToken, + User: &model.User{ + ID: userIdStr, + Email: user.Email, + Image: &user.Image, + FirstName: &user.FirstName, + LastName: &user.LastName, + }, + } + + utils.SetCookie(gc, accessToken) + + return res, nil } func (r *queryResolver) Users(ctx context.Context) ([]*model.User, error) { @@ -180,6 +190,10 @@ func (r *queryResolver) Users(ctx context.Context) ([]*model.User, error) { return res, nil } +func (r *queryResolver) UpdateToken(ctx context.Context) (*model.LoginResponse, error) { + panic(fmt.Errorf("not implemented")) +} + // Mutation returns generated.MutationResolver implementation. func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} } diff --git a/server/server.go b/server/server.go index 2eed843..d9fb61c 100644 --- a/server/server.go +++ b/server/server.go @@ -1,30 +1,47 @@ package main import ( - "log" - "net/http" - "os" + "context" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/playground" + "github.com/gin-gonic/gin" "github.com/yauthdev/yauth/server/graph" "github.com/yauthdev/yauth/server/graph/generated" ) -const defaultPort = "8080" +// Defining the Graphql handler +func graphqlHandler() gin.HandlerFunc { + // NewExecutableSchema and Config are in the generated.go file + // Resolver is in the resolver.go file + h := handler.NewDefaultServer(generated.NewExecutableSchema(generated.Config{Resolvers: &graph.Resolver{}})) + + return func(c *gin.Context) { + h.ServeHTTP(c.Writer, c.Request) + } +} + +// Defining the Playground handler +func playgroundHandler() gin.HandlerFunc { + h := playground.Handler("GraphQL", "/graphql") + + return func(c *gin.Context) { + h.ServeHTTP(c.Writer, c.Request) + } +} + +func GinContextToContextMiddleware() gin.HandlerFunc { + return func(c *gin.Context) { + ctx := context.WithValue(c.Request.Context(), "GinContextKey", c) + c.Request = c.Request.WithContext(ctx) + c.Next() + } +} func main() { - port := os.Getenv("PORT") - if port == "" { - port = defaultPort - } - - srv := handler.NewDefaultServer(generated.NewExecutableSchema(generated.Config{Resolvers: &graph.Resolver{}})) - - http.Handle("/", playground.Handler("GraphQL playground", "/graphql")) - http.Handle("/graphql", srv) - - log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) - - log.Fatal(http.ListenAndServe(":"+port, nil)) + r := gin.Default() + r.Use(GinContextToContextMiddleware()) + r.POST("/graphql", graphqlHandler()) + r.GET("/", playgroundHandler()) + r.Run() } diff --git a/server/session/inMemoryStore.go b/server/session/inMemoryStore.go new file mode 100644 index 0000000..ee76e46 --- /dev/null +++ b/server/session/inMemoryStore.go @@ -0,0 +1,41 @@ +package session + +import "sync" + +type InMemoryStore struct { + mu sync.Mutex + store map[string]string +} + +func (c *InMemoryStore) AddToken(userId, token string) { + c.mu.Lock() + // delete sessions > 500 // not recommended for production + if len(c.store) >= 500 { + c.store = make(map[string]string) + } + c.store[userId] = token + c.mu.Unlock() +} + +func (c *InMemoryStore) DeleteToken(userId string) { + c.mu.Lock() + delete(c.store, userId) + c.mu.Unlock() +} + +func (c *InMemoryStore) ClearStore() { + c.mu.Lock() + c.store = make(map[string]string) + c.mu.Unlock() +} + +func (c *InMemoryStore) GetToken(userId string) string { + token := "" + c.mu.Lock() + if val, ok := c.store[userId]; ok { + token = val + } + c.mu.Unlock() + + return token +} diff --git a/server/session/redisStore.go b/server/session/redisStore.go new file mode 100644 index 0000000..d6fd20f --- /dev/null +++ b/server/session/redisStore.go @@ -0,0 +1,43 @@ +package session + +import ( + "context" + "log" + + "github.com/go-redis/redis/v8" +) + +type RedisStore struct { + ctx context.Context + store *redis.Client +} + +func (c *RedisStore) AddToken(userId, token string) { + err := c.store.Set(c.ctx, "yauth_"+userId, token, 0).Err() + if err != nil { + log.Fatalln("Error saving redis token:", err) + } +} + +func (c *RedisStore) DeleteToken(userId string) { + err := c.store.Del(c.ctx, "yauth_"+userId).Err() + if err != nil { + log.Fatalln("Error deleting redis token:", err) + } +} + +func (c *RedisStore) ClearStore() { + err := c.store.Del(c.ctx, "yauth_*").Err() + if err != nil { + log.Fatalln("Error clearing redis store:", err) + } +} + +func (c *RedisStore) GetToken(userId string) string { + token := "" + token, err := c.store.Get(c.ctx, "yauth_"+userId).Result() + if err != nil { + log.Println("Error getting token from redis store:", err) + } + return token +} diff --git a/server/session/session.go b/server/session/session.go new file mode 100644 index 0000000..85f6b25 --- /dev/null +++ b/server/session/session.go @@ -0,0 +1,81 @@ +package session + +import ( + "context" + "log" + + "github.com/go-redis/redis/v8" + "github.com/yauthdev/yauth/server/constants" +) + +type SessionStore struct { + inMemoryStoreObj *InMemoryStore + redisMemoryStoreObj *RedisStore +} + +var SessionStoreObj SessionStore + +func SetToken(userId, token string) { + if SessionStoreObj.redisMemoryStoreObj != nil { + SessionStoreObj.redisMemoryStoreObj.AddToken(userId, token) + } + if SessionStoreObj.inMemoryStoreObj != nil { + SessionStoreObj.inMemoryStoreObj.AddToken(userId, token) + } +} + +func DeleteToken(userId string) { + if SessionStoreObj.redisMemoryStoreObj != nil { + SessionStoreObj.redisMemoryStoreObj.DeleteToken(userId) + } + if SessionStoreObj.inMemoryStoreObj != nil { + SessionStoreObj.inMemoryStoreObj.DeleteToken(userId) + } +} + +func GetToken(userId string) string { + if SessionStoreObj.redisMemoryStoreObj != nil { + return SessionStoreObj.redisMemoryStoreObj.GetToken(userId) + } + if SessionStoreObj.inMemoryStoreObj != nil { + return SessionStoreObj.inMemoryStoreObj.GetToken(userId) + } + + return "" +} + +func ClearStore() { + if SessionStoreObj.redisMemoryStoreObj != nil { + SessionStoreObj.redisMemoryStoreObj.ClearStore() + } + if SessionStoreObj.inMemoryStoreObj != nil { + SessionStoreObj.inMemoryStoreObj.ClearStore() + } +} + +func init() { + if constants.REDIS_URL != "" { + log.Println("Using redis store to save sessions") + opt, err := redis.ParseURL(constants.REDIS_URL) + if err != nil { + log.Fatalln("Error parsing redis url:", err) + } + rdb := redis.NewClient(opt) + ctx := context.Background() + _, err = rdb.Ping(ctx).Result() + + if err != nil { + log.Fatalln("Error connecting to redis server", err) + } + SessionStoreObj.redisMemoryStoreObj = &RedisStore{ + ctx: ctx, + store: rdb, + } + + } else { + log.Println("Using in memory store to save sessions") + SessionStoreObj.inMemoryStoreObj = &InMemoryStore{ + store: make(map[string]string), + } + } +} diff --git a/server/utils/authToken.go b/server/utils/authToken.go new file mode 100644 index 0000000..0343855 --- /dev/null +++ b/server/utils/authToken.go @@ -0,0 +1,39 @@ +package utils + +import ( + "time" + + "github.com/golang-jwt/jwt" + "github.com/yauthdev/yauth/server/constants" + "github.com/yauthdev/yauth/server/enum" +) + +type UserAuthInfo struct { + Email string `json:"email"` + ID string `json:"id"` +} + +type UserAuthClaim struct { + *jwt.StandardClaims + TokenType string `json:"token_type"` + UserAuthInfo +} + +func CreateAuthToken(user UserAuthInfo, tokenType enum.TokenType) (string, error) { + t := jwt.New(jwt.GetSigningMethod(constants.JWT_TYPE)) + expiryBound := time.Hour + if tokenType == enum.RefreshToken { + // expires in 90 days + expiryBound = time.Hour * 2160 + } + + t.Claims = &UserAuthClaim{ + &jwt.StandardClaims{ + ExpiresAt: time.Now().Add(expiryBound).Unix(), + }, + tokenType.String(), + user, + } + + return t.SignedString([]byte(constants.JWT_SECRET)) +} diff --git a/server/utils/cookie.go b/server/utils/cookie.go new file mode 100644 index 0000000..03b2598 --- /dev/null +++ b/server/utils/cookie.go @@ -0,0 +1,17 @@ +package utils + +import ( + "github.com/gin-gonic/gin" + "github.com/yauthdev/yauth/server/constants" +) + +func SetCookie(gc *gin.Context, token string) { + secure := true + httpOnly := true + + if !constants.IS_PROD { + secure = false + } + + gc.SetCookie(constants.COOKIE_NAME, token, 3600, "/", GetFrontendHost(), secure, httpOnly) +} diff --git a/server/utils/ginContext.go b/server/utils/ginContext.go new file mode 100644 index 0000000..cdcf1e1 --- /dev/null +++ b/server/utils/ginContext.go @@ -0,0 +1,23 @@ +package utils + +import ( + "context" + "fmt" + + "github.com/gin-gonic/gin" +) + +func GinContextFromContext(ctx context.Context) (*gin.Context, error) { + ginContext := ctx.Value("GinContextKey") + if ginContext == nil { + err := fmt.Errorf("could not retrieve gin.Context") + return nil, err + } + + gc, ok := ginContext.(*gin.Context) + if !ok { + err := fmt.Errorf("gin.Context has wrong type") + return nil, err + } + return gc, nil +} diff --git a/server/utils/urls.go b/server/utils/urls.go new file mode 100644 index 0000000..126b617 --- /dev/null +++ b/server/utils/urls.go @@ -0,0 +1,16 @@ +package utils + +import ( + "net/url" + + "github.com/yauthdev/yauth/server/constants" +) + +func GetFrontendHost() string { + u, err := url.Parse(constants.FRONTEND_URL) + if err != nil { + return `localhost` + } + + return u.Hostname() +}