diff --git a/TODO.md b/TODO.md index 6870f7f..0dda0e5 100644 --- a/TODO.md +++ b/TODO.md @@ -1,5 +1,19 @@ # Task List +## Open ID compatible claims and schema + +- [x] Rename `schema.graphqls` and re generate schema +- [x] Rename to snake case [files + schema] +- [x] Refactor db models +- [x] Check extra data in oauth profile and save accordingly +- [x] Update all the resolver to make them compatible with schema changes +- [x] Update JWT claims +- [] Write integration tests for all resolvers +- [] Update doc + - [] Rename all schemas + vars +- [] Update JS lib +- [] Update react lib + ## Feature Multiple sessions - Multiple sessions for users to login use hMset from redis for this diff --git a/server/constants/constants.go b/server/constants/constants.go index 30b119c..0d0d338 100644 --- a/server/constants/constants.go +++ b/server/constants/constants.go @@ -1,5 +1,6 @@ package constants +// this constants are configured via env var ( ADMIN_SECRET = "" ENV = "" @@ -17,14 +18,14 @@ var ( ALLOWED_ORIGINS = []string{} AUTHORIZER_URL = "" APP_URL = "" - PORT = "8080" + PORT = "" REDIS_URL = "" IS_PROD = false COOKIE_NAME = "" RESET_PASSWORD_URL = "" DISABLE_EMAIL_VERIFICATION = false DISABLE_BASIC_AUTHENTICATION = false - DISABLE_MAGIC_LOGIN = false + DISABLE_MAGIC_LINK_LOGIN = false // ROLES ROLES = []string{} diff --git a/server/constants/oauthInfoUrls.go b/server/constants/oauth_info_urls.go similarity index 100% rename from server/constants/oauthInfoUrls.go rename to server/constants/oauth_info_urls.go diff --git a/server/db/arangodb.go b/server/db/arangodb.go index e577d2b..303498d 100644 --- a/server/db/arangodb.go +++ b/server/db/arangodb.go @@ -61,11 +61,11 @@ func initArangodb() (arangoDriver.Database, error) { } } userCollection, _ := arangodb.Collection(nil, Collections.User) - userCollection.EnsureHashIndex(ctx, []string{"id"}, &arangoDriver.EnsureHashIndexOptions{ + userCollection.EnsureHashIndex(ctx, []string{"email"}, &arangoDriver.EnsureHashIndexOptions{ Unique: true, Sparse: true, }) - userCollection.EnsureHashIndex(ctx, []string{"email"}, &arangoDriver.EnsureHashIndexOptions{ + userCollection.EnsureHashIndex(ctx, []string{"phone_number"}, &arangoDriver.EnsureHashIndexOptions{ Unique: true, Sparse: true, }) @@ -79,11 +79,8 @@ func initArangodb() (arangoDriver.Database, error) { log.Println("error creating collection("+Collections.VerificationRequest+"):", err) } } + verificationRequestCollection, _ := arangodb.Collection(nil, Collections.VerificationRequest) - verificationRequestCollection.EnsureHashIndex(ctx, []string{"id"}, &arangoDriver.EnsureHashIndexOptions{ - Unique: true, - Sparse: true, - }) verificationRequestCollection.EnsureHashIndex(ctx, []string{"email", "identifier"}, &arangoDriver.EnsureHashIndexOptions{ Unique: true, Sparse: true, @@ -102,11 +99,5 @@ func initArangodb() (arangoDriver.Database, error) { } } - sessionCollection, _ := arangodb.Collection(nil, Collections.Session) - sessionCollection.EnsureHashIndex(ctx, []string{"id"}, &arangoDriver.EnsureHashIndexOptions{ - Unique: true, - Sparse: true, - }) - return arangodb, err } diff --git a/server/db/mongodb.go b/server/db/mongodb.go index d0b1c55..f92dcb2 100644 --- a/server/db/mongodb.go +++ b/server/db/mongodb.go @@ -46,6 +46,12 @@ func initMongodb() (*mongo.Database, error) { Options: options.Index().SetUnique(true).SetSparse(true), }, }, options.CreateIndexes()) + userCollection.Indexes().CreateMany(ctx, []mongo.IndexModel{ + mongo.IndexModel{ + Keys: bson.M{"phone_number": 1}, + Options: options.Index().SetUnique(true).SetSparse(true), + }, + }, options.CreateIndexes()) mongodb.CreateCollection(ctx, Collections.VerificationRequest, options.CreateCollection()) verificationRequestCollection := mongodb.Collection(Collections.VerificationRequest, options.Collection()) diff --git a/server/db/session.go b/server/db/session.go index 574696a..22c3ea2 100644 --- a/server/db/session.go +++ b/server/db/session.go @@ -10,9 +10,9 @@ import ( ) type Session struct { - Key string `json:"_key,omitempty" bson:"_key,omitempty"` // for arangodb - ObjectID string `json:"_id,omitempty" bson:"_id"` // for arangodb & mongodb - ID string `gorm:"primaryKey;type:char(36)" json:"id" bson:"id"` + Key string `json:"_key,omitempty" bson:"_key,omitempty"` // for arangodb + // ObjectID string `json:"_id,omitempty" bson:"_id"` // for arangodb & mongodb + ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id"` UserID string `gorm:"type:char(36)" json:"user_id" bson:"user_id"` User User `json:"-" bson:"-"` UserAgent string `json:"user_agent" bson:"user_agent"` @@ -29,7 +29,7 @@ func (mgr *manager) AddSession(session Session) error { if IsORMSupported { session.Key = session.ID - session.ObjectID = session.ID + // session.ObjectID = session.ID res := mgr.sqlDB.Clauses( clause.OnConflict{ DoNothing: true, @@ -53,7 +53,7 @@ func (mgr *manager) AddSession(session Session) error { if IsMongoDB { session.Key = session.ID - session.ObjectID = session.ID + // session.ObjectID = session.ID session.CreatedAt = time.Now().Unix() session.UpdatedAt = time.Now().Unix() sessionCollection := mgr.mongodb.Collection(Collections.Session, options.Collection()) diff --git a/server/db/user.go b/server/db/user.go index 0b58d30..42387ca 100644 --- a/server/db/user.go +++ b/server/db/user.go @@ -14,19 +14,25 @@ import ( ) type User struct { - Key string `json:"_key,omitempty" bson:"_key"` // for arangodb - ObjectID string `json:"_id,omitempty" bson:"_id"` // for arangodb & mongodb - ID string `gorm:"primaryKey;type:char(36)" json:"id" bson:"id"` - FirstName string `json:"first_name" bson:"first_name"` - LastName string `json:"last_name" bson:"last_name"` - Email string `gorm:"unique" json:"email" bson:"email"` - Password string `gorm:"type:text" json:"password" bson:"password"` - SignupMethod string `json:"signup_method" bson:"signup_method"` - EmailVerifiedAt int64 `json:"email_verified_at" bson:"email_verified_at"` - CreatedAt int64 `gorm:"autoCreateTime" json:"created_at" bson:"created_at"` - UpdatedAt int64 `gorm:"autoUpdateTime" json:"updated_at" bson:"updated_at"` - Image string `gorm:"type:text" json:"image" bson:"image"` - Roles string `json:"roles" bson:"roles"` + Key string `json:"_key,omitempty" bson:"_key"` // for arangodb + ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id"` + + Email string `gorm:"unique" json:"email" bson:"email"` + EmailVerifiedAt int64 `json:"email_verified_at" bson:"email_verified_at"` + Password string `gorm:"type:text" json:"password" bson:"password"` + SignupMethods string `json:"signup_methods" bson:"signup_methods"` + GivenName string `json:"given_name" bson:"given_name"` + FamilyName string `json:"family_name" bson:"family_name"` + MiddleName string `json:"middle_name" bson:"middle_name"` + Nickname string `json:"nickname" bson:"nickname"` + Gender string `json:"gender" bson:"gender"` + Birthdate string `json:"birthdate" bson:"birthdate"` + PhoneNumber string `gorm:"unique" json:"phone_number" bson:"phone_number"` + PhoneNumberVerifiedAt int64 `json:"phone_number_verified_at" bson:"phone_number_verified_at"` + Picture string `gorm:"type:text" json:"picture" bson:"picture"` + Roles string `json:"roles" bson:"roles"` + UpdatedAt int64 `gorm:"autoUpdateTime" json:"updated_at" bson:"updated_at"` + CreatedAt int64 `gorm:"autoCreateTime" json:"created_at" bson:"created_at"` } // AddUser function to add user even with email conflict @@ -38,7 +44,7 @@ func (mgr *manager) AddUser(user User) (User, error) { if IsORMSupported { // copy id as value for fields required for mongodb & arangodb user.Key = user.ID - user.ObjectID = user.ID + // user.ObjectID = user.ID result := mgr.sqlDB.Clauses( clause.OnConflict{ UpdateAll: true, @@ -61,14 +67,14 @@ func (mgr *manager) AddUser(user User) (User, error) { return user, err } user.Key = meta.Key - user.ObjectID = meta.ID.String() + // user.ObjectID = meta.ID.String() } if IsMongoDB { user.CreatedAt = time.Now().Unix() user.UpdatedAt = time.Now().Unix() user.Key = user.ID - user.ObjectID = user.ID + // user.ObjectID = user.ID userCollection := mgr.mongodb.Collection(Collections.User, options.Collection()) _, err := userCollection.InsertOne(nil, user) if err != nil { @@ -102,7 +108,7 @@ func (mgr *manager) UpdateUser(user User) (User, error) { } user.Key = meta.Key - user.ObjectID = meta.ID.String() + // user.ObjectID = meta.ID.String() } if IsMongoDB { diff --git a/server/db/verificationRequests.go b/server/db/verification_requests.go similarity index 95% rename from server/db/verificationRequests.go rename to server/db/verification_requests.go index 8a9d271..295be44 100644 --- a/server/db/verificationRequests.go +++ b/server/db/verification_requests.go @@ -13,9 +13,9 @@ import ( ) type VerificationRequest struct { - Key string `json:"_key,omitempty" bson:"_key"` // for arangodb - ObjectID string `json:"_id,omitempty" bson:"_id"` // for arangodb & mongodb - ID string `gorm:"primaryKey;type:char(36)" json:"id" bson:"id"` + Key string `json:"_key,omitempty" bson:"_key"` // for arangodb + // ObjectID string `json:"_id,omitempty" bson:"_id"` // for arangodb & mongodb + ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id"` Token string `gorm:"type:text" json:"token" bson:"token"` Identifier string `gorm:"uniqueIndex:idx_email_identifier" json:"identifier" bson:"identifier"` ExpiresAt int64 `json:"expires_at" bson:"expires_at"` @@ -32,7 +32,7 @@ func (mgr *manager) AddVerification(verification VerificationRequest) (Verificat if IsORMSupported { // copy id as value for fields required for mongodb & arangodb verification.Key = verification.ID - verification.ObjectID = verification.ID + // verification.ObjectID = verification.ID result := mgr.sqlDB.Clauses(clause.OnConflict{ Columns: []clause.Column{{Name: "email"}, {Name: "identifier"}}, DoUpdates: clause.AssignmentColumns([]string{"token", "expires_at"}), @@ -54,14 +54,14 @@ func (mgr *manager) AddVerification(verification VerificationRequest) (Verificat return verification, err } verification.Key = meta.Key - verification.ObjectID = meta.ID.String() + // verification.ObjectID = meta.ID.String() } if IsMongoDB { verification.CreatedAt = time.Now().Unix() verification.UpdatedAt = time.Now().Unix() verification.Key = verification.ID - verification.ObjectID = verification.ID + // verification.ObjectID = verification.ID verificationRequestCollection := mgr.mongodb.Collection(Collections.VerificationRequest, options.Collection()) _, err := verificationRequestCollection.InsertOne(nil, verification) if err != nil { diff --git a/server/enum/dbType.go b/server/enum/db_types.go similarity index 100% rename from server/enum/dbType.go rename to server/enum/db_types.go diff --git a/server/enum/oauthProvider.go b/server/enum/oauth_providers.go similarity index 100% rename from server/enum/oauthProvider.go rename to server/enum/oauth_providers.go diff --git a/server/enum/signUpMethod.go b/server/enum/signup_methods.go similarity index 100% rename from server/enum/signUpMethod.go rename to server/enum/signup_methods.go diff --git a/server/enum/tokenType.go b/server/enum/token_types.go similarity index 100% rename from server/enum/tokenType.go rename to server/enum/token_types.go diff --git a/server/enum/verification.go b/server/enum/verification_types.go similarity index 100% rename from server/enum/verification.go rename to server/enum/verification_types.go diff --git a/server/env/env.go b/server/env/env.go index 931cd72..f103d56 100644 --- a/server/env/env.go +++ b/server/env/env.go @@ -41,48 +41,149 @@ func InitEnv() { } constants.VERSION = VERSION - constants.ADMIN_SECRET = os.Getenv("ADMIN_SECRET") - constants.ENV = os.Getenv("ENV") - constants.DATABASE_TYPE = os.Getenv("DATABASE_TYPE") - constants.DATABASE_URL = os.Getenv("DATABASE_URL") - constants.DATABASE_NAME = os.Getenv("DATABASE_NAME") - constants.SMTP_HOST = os.Getenv("SMTP_HOST") - constants.SMTP_PORT = os.Getenv("SMTP_PORT") - constants.SENDER_EMAIL = os.Getenv("SENDER_EMAIL") - constants.SENDER_PASSWORD = os.Getenv("SENDER_PASSWORD") - constants.JWT_SECRET = os.Getenv("JWT_SECRET") - constants.JWT_TYPE = os.Getenv("JWT_TYPE") - constants.AUTHORIZER_URL = strings.TrimSuffix(os.Getenv("AUTHORIZER_URL"), "/") - constants.PORT = os.Getenv("PORT") - constants.REDIS_URL = os.Getenv("REDIS_URL") - constants.COOKIE_NAME = os.Getenv("COOKIE_NAME") - constants.GOOGLE_CLIENT_ID = os.Getenv("GOOGLE_CLIENT_ID") - constants.GOOGLE_CLIENT_SECRET = os.Getenv("GOOGLE_CLIENT_SECRET") - constants.GITHUB_CLIENT_ID = os.Getenv("GITHUB_CLIENT_ID") - constants.GITHUB_CLIENT_SECRET = os.Getenv("GITHUB_CLIENT_SECRET") - constants.FACEBOOK_CLIENT_ID = os.Getenv("FACEBOOK_CLIENT_ID") - constants.FACEBOOK_CLIENT_SECRET = os.Getenv("FACEBOOK_CLIENT_SECRET") - constants.TWITTER_CLIENT_ID = os.Getenv("TWITTER_CLIENT_ID") - constants.TWITTER_CLIENT_SECRET = os.Getenv("TWITTER_CLIENT_SECRET") - constants.RESET_PASSWORD_URL = strings.TrimPrefix(os.Getenv("RESET_PASSWORD_URL"), "/") - constants.DISABLE_BASIC_AUTHENTICATION = os.Getenv("DISABLE_BASIC_AUTHENTICATION") == "true" - constants.DISABLE_EMAIL_VERIFICATION = os.Getenv("DISABLE_EMAIL_VERIFICATION") == "true" - constants.DISABLE_MAGIC_LOGIN = os.Getenv("DISABLE_MAGIC_LOGIN") == "true" - constants.JWT_ROLE_CLAIM = os.Getenv("JWT_ROLE_CLAIM") if constants.ADMIN_SECRET == "" { - panic("root admin secret is required") + constants.ADMIN_SECRET = os.Getenv("ADMIN_SECRET") + if constants.ADMIN_SECRET == "" { + panic("root admin secret is required") + } } if constants.ENV == "" { - constants.ENV = "production" + constants.ENV = os.Getenv("ENV") + if constants.ENV == "" { + constants.ENV = "production" + } + + if constants.ENV == "production" { + constants.IS_PROD = true + os.Setenv("GIN_MODE", "release") + } else { + constants.IS_PROD = false + } } - if constants.ENV == "production" { - constants.IS_PROD = true - os.Setenv("GIN_MODE", "release") - } else { - constants.IS_PROD = false + if constants.DATABASE_TYPE == "" { + constants.DATABASE_TYPE = os.Getenv("DATABASE_TYPE") + + if *ARG_DB_TYPE != "" { + constants.DATABASE_TYPE = *ARG_DB_TYPE + } + + if constants.DATABASE_TYPE == "" { + panic("DATABASE_TYPE is required") + } + } + + if constants.DATABASE_URL == "" { + constants.DATABASE_URL = os.Getenv("DATABASE_URL") + + if *ARG_DB_URL != "" { + constants.DATABASE_URL = *ARG_DB_URL + } + + if constants.DATABASE_URL == "" { + panic("DATABASE_URL is required") + } + } + + if constants.DATABASE_NAME == "" { + constants.DATABASE_NAME = os.Getenv("DATABASE_NAME") + if constants.DATABASE_NAME == "" { + constants.DATABASE_NAME = "authorizer" + } + } + + if constants.SMTP_HOST == "" { + constants.SMTP_HOST = os.Getenv("SMTP_HOST") + } + + if constants.SMTP_PORT == "" { + constants.SMTP_PORT = os.Getenv("SMTP_PORT") + } + + if constants.SENDER_EMAIL == "" { + constants.SENDER_EMAIL = os.Getenv("SENDER_EMAIL") + } + + if constants.SENDER_PASSWORD == "" { + constants.SENDER_PASSWORD = os.Getenv("SENDER_PASSWORD") + } + + if constants.JWT_SECRET == "" { + constants.JWT_SECRET = os.Getenv("JWT_SECRET") + } + + if constants.JWT_TYPE == "" { + constants.JWT_TYPE = os.Getenv("JWT_TYPE") + } + + if constants.JWT_ROLE_CLAIM == "" { + constants.JWT_ROLE_CLAIM = os.Getenv("JWT_ROLE_CLAIM") + + if constants.JWT_ROLE_CLAIM == "" { + constants.JWT_ROLE_CLAIM = "role" + } + } + + if constants.AUTHORIZER_URL == "" { + constants.AUTHORIZER_URL = strings.TrimSuffix(os.Getenv("AUTHORIZER_URL"), "/") + + if *ARG_AUTHORIZER_URL != "" { + constants.AUTHORIZER_URL = *ARG_AUTHORIZER_URL + } + } + + if constants.PORT == "" { + constants.PORT = os.Getenv("PORT") + if constants.PORT == "" { + constants.PORT = "8080" + } + } + + if constants.REDIS_URL == "" { + constants.REDIS_URL = os.Getenv("REDIS_URL") + } + + if constants.COOKIE_NAME == "" { + constants.COOKIE_NAME = os.Getenv("COOKIE_NAME") + } + + if constants.GOOGLE_CLIENT_ID == "" { + constants.GOOGLE_CLIENT_ID = os.Getenv("GOOGLE_CLIENT_ID") + } + + if constants.GOOGLE_CLIENT_SECRET == "" { + constants.GOOGLE_CLIENT_SECRET = os.Getenv("GOOGLE_CLIENT_SECRET") + } + + if constants.GITHUB_CLIENT_ID == "" { + constants.GITHUB_CLIENT_ID = os.Getenv("GITHUB_CLIENT_ID") + } + + if constants.GITHUB_CLIENT_SECRET == "" { + constants.GITHUB_CLIENT_SECRET = os.Getenv("GITHUB_CLIENT_SECRET") + } + + if constants.FACEBOOK_CLIENT_ID == "" { + constants.FACEBOOK_CLIENT_ID = os.Getenv("FACEBOOK_CLIENT_ID") + } + + if constants.FACEBOOK_CLIENT_SECRET == "" { + constants.FACEBOOK_CLIENT_SECRET = os.Getenv("FACEBOOK_CLIENT_SECRET") + } + + if constants.RESET_PASSWORD_URL == "" { + constants.RESET_PASSWORD_URL = strings.TrimPrefix(os.Getenv("RESET_PASSWORD_URL"), "/") + } + + constants.DISABLE_BASIC_AUTHENTICATION = os.Getenv("DISABLE_BASIC_AUTHENTICATION") == "true" + constants.DISABLE_EMAIL_VERIFICATION = os.Getenv("DISABLE_EMAIL_VERIFICATION") == "true" + constants.DISABLE_MAGIC_LINK_LOGIN = os.Getenv("DISABLE_MAGIC_LINK_LOGIN") == "true" + + if constants.SMTP_HOST == "" || constants.SENDER_EMAIL == "" || constants.SENDER_PASSWORD == "" { + constants.DISABLE_EMAIL_VERIFICATION = true + constants.DISABLE_MAGIC_LINK_LOGIN = true } allowedOriginsSplit := strings.Split(os.Getenv("ALLOWED_ORIGINS"), ",") @@ -113,30 +214,6 @@ func InitEnv() { constants.ALLOWED_ORIGINS = allowedOrigins - if *ARG_AUTHORIZER_URL != "" { - constants.AUTHORIZER_URL = *ARG_AUTHORIZER_URL - } - - if *ARG_DB_URL != "" { - constants.DATABASE_URL = *ARG_DB_URL - } - - if *ARG_DB_TYPE != "" { - constants.DATABASE_TYPE = *ARG_DB_TYPE - } - - if constants.DATABASE_URL == "" { - panic("Database url is required") - } - - if constants.DATABASE_TYPE == "" { - panic("Database type is required") - } - - if constants.DATABASE_NAME == "" { - constants.DATABASE_NAME = "authorizer" - } - if constants.JWT_TYPE == "" { constants.JWT_TYPE = "HS256" } @@ -145,13 +222,8 @@ func InitEnv() { constants.COOKIE_NAME = "authorizer" } - if constants.SMTP_HOST == "" || constants.SENDER_EMAIL == "" || constants.SENDER_PASSWORD == "" { - constants.DISABLE_EMAIL_VERIFICATION = true - constants.DISABLE_MAGIC_LOGIN = true - } - if constants.DISABLE_EMAIL_VERIFICATION { - constants.DISABLE_MAGIC_LOGIN = true + constants.DISABLE_MAGIC_LINK_LOGIN = true } rolesSplit := strings.Split(os.Getenv("ROLES"), ",") @@ -196,10 +268,6 @@ func InitEnv() { constants.DEFAULT_ROLES = defaultRoles constants.PROTECTED_ROLES = protectedRoles - if constants.JWT_ROLE_CLAIM == "" { - constants.JWT_ROLE_CLAIM = "role" - } - if os.Getenv("ORGANIZATION_NAME") != "" { constants.ORGANIZATION_NAME = os.Getenv("ORGANIZATION_NAME") } diff --git a/server/env/env_test.go b/server/env/env_test.go index fa72912..9c0a764 100644 --- a/server/env/env_test.go +++ b/server/env/env_test.go @@ -10,6 +10,8 @@ import ( func TestEnvs(t *testing.T) { constants.ENV_PATH = "../../.env.sample" + constants.DATABASE_TYPE = "sqlite" + constants.DATABASE_URL = "data.db" InitEnv() assert.Equal(t, constants.ADMIN_SECRET, "admin") @@ -17,7 +19,7 @@ func TestEnvs(t *testing.T) { assert.Equal(t, constants.DATABASE_URL, "data.db") assert.Equal(t, constants.DATABASE_TYPE, enum.Sqlite.String()) assert.True(t, constants.DISABLE_EMAIL_VERIFICATION) - assert.True(t, constants.DISABLE_MAGIC_LOGIN) + assert.True(t, constants.DISABLE_MAGIC_LINK_LOGIN) assert.False(t, constants.DISABLE_BASIC_AUTHENTICATION) assert.Equal(t, constants.JWT_TYPE, "HS256") assert.Equal(t, constants.JWT_SECRET, "random_string") diff --git a/server/go.mod b/server/go.mod index 9060d42..04b55a4 100644 --- a/server/go.mod +++ b/server/go.mod @@ -3,7 +3,7 @@ module github.com/authorizerdev/authorizer/server go 1.16 require ( - github.com/99designs/gqlgen v0.13.0 + github.com/99designs/gqlgen v0.14.0 github.com/arangodb/go-driver v1.2.1 github.com/coreos/go-oidc/v3 v3.1.0 github.com/gin-contrib/location v0.0.2 @@ -20,10 +20,10 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.1 // indirect github.com/robertkrimen/otto v0.0.0-20211024170158-b87d35c0b86f - github.com/stretchr/testify v1.7.0 // indirect + github.com/stretchr/testify v1.7.0 github.com/ugorji/go v1.2.6 // indirect - github.com/vektah/gqlparser/v2 v2.1.0 - go.mongodb.org/mongo-driver v1.8.1 // indirect + github.com/vektah/gqlparser/v2 v2.2.0 + go.mongodb.org/mongo-driver v1.8.1 golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914 diff --git a/server/go.sum b/server/go.sum index 9006fb1..8ca7d0a 100644 --- a/server/go.sum +++ b/server/go.sum @@ -31,15 +31,15 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/99designs/gqlgen v0.13.0 h1:haLTcUp3Vwp80xMVEg5KRNwzfUrgFdRmtBY8fuB8scA= -github.com/99designs/gqlgen v0.13.0/go.mod h1:NV130r6f4tpRWuAI+zsrSdooO/eWUv+Gyyoi3rEfXIk= +github.com/99designs/gqlgen v0.14.0 h1:Wg8aNYQUjMR/4v+W3xD+7SizOy6lSvVeQ06AobNQAXI= +github.com/99designs/gqlgen v0.14.0/go.mod h1:S7z4boV+Nx4VvzMUpVrY/YuHjFX4n7rDyuTqvAkuoRE= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= -github.com/agnivade/levenshtein v1.0.3 h1:M5ZnqLOoZR8ygVq0FfkXsNOKzMCk0xRiow0R5+5VkQ0= -github.com/agnivade/levenshtein v1.0.3/go.mod h1:4SFRZbbXWLF4MU1T9Qg0pGgH3Pjs+t6ie5efyrwRJXs= +github.com/agnivade/levenshtein v1.1.0 h1:n6qGwyHG61v3ABce1rPVZklEYRT8NFpCMrpZdBUbYGM= +github.com/agnivade/levenshtein v1.1.0/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= github.com/arangodb/go-driver v1.2.1 h1:HREDHhDmzdIWxHmfkfTESbYUnRjESjPh4WUuXq7FZa8= @@ -73,8 +73,8 @@ github.com/denisenkom/go-mssqldb v0.11.0 h1:9rHa233rhdOyrz2GcP9NM+gi2psgJZ4GWDpL github.com/denisenkom/go-mssqldb v0.11.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= 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 h1:TUuUh0Xgj97tLMNtWtNvI9mIV6isjEb9lBMNv+77IGM= -github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= +github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g= +github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -89,7 +89,6 @@ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= 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-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -113,7 +112,7 @@ github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= @@ -246,6 +245,7 @@ github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMW github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= @@ -328,7 +328,6 @@ github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMB github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -338,6 +337,7 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go v1.2.6 h1:tGiWC9HENWE2tqYycIqFTNorMmFRVhNwCpDOpWqnk8E= @@ -347,8 +347,8 @@ github.com/ugorji/go/codec v1.2.6 h1:7kbGefxLoDBuYXOms4yD7223OpNMMPNPZxXk5TvFcyQ github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw= github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U= -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/vektah/gqlparser/v2 v2.2.0 h1:bAc3slekAAJW6sZTi07aGq0OrfaCjj4jxARAaC7g2EM= +github.com/vektah/gqlparser/v2 v2.2.0/go.mod h1:i3mQIGIrbK2PD1RrCeMTlVbkF2FJ6WkU1KJlJlC+3F4= github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.0.2 h1:akYIkZ28e6A96dkWNJQu3nmCzH3YfwMPQExUYDaRv7w= @@ -565,7 +565,6 @@ golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= @@ -581,10 +580,12 @@ golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/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= @@ -715,5 +716,5 @@ honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= +sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k= diff --git a/server/graph/generated/generated.go b/server/graph/generated/generated.go index db8919b..fbc197d 100644 --- a/server/graph/generated/generated.go +++ b/server/graph/generated/generated.go @@ -44,10 +44,10 @@ type DirectiveRoot struct { type ComplexityRoot struct { AuthResponse struct { - AccessToken func(childComplexity int) int - AccessTokenExpiresAt func(childComplexity int) int - Message func(childComplexity int) int - User func(childComplexity int) int + AccessToken func(childComplexity int) int + ExpiresAt func(childComplexity int) int + Message func(childComplexity int) int + User func(childComplexity int) int } Error struct { @@ -61,22 +61,21 @@ type ComplexityRoot struct { IsFacebookLoginEnabled func(childComplexity int) int IsGithubLoginEnabled func(childComplexity int) int IsGoogleLoginEnabled func(childComplexity int) int - IsMagicLoginEnabled func(childComplexity int) int - IsTwitterLoginEnabled func(childComplexity int) int + IsMagicLinkLoginEnabled func(childComplexity int) int Version func(childComplexity int) int } Mutation struct { - AdminUpdateUser func(childComplexity int, params model.AdminUpdateUserInput) int DeleteUser func(childComplexity int, params model.DeleteUserInput) int ForgotPassword func(childComplexity int, params model.ForgotPasswordInput) int Login func(childComplexity int, params model.LoginInput) int Logout func(childComplexity int) int - MagicLogin func(childComplexity int, params model.MagicLoginInput) int + MagicLinkLogin func(childComplexity int, params model.MagicLinkLoginInput) int ResendVerifyEmail func(childComplexity int, params model.ResendVerifyEmailInput) int ResetPassword func(childComplexity int, params model.ResetPasswordInput) int Signup func(childComplexity int, params model.SignUpInput) int UpdateProfile func(childComplexity int, params model.UpdateProfileInput) int + UpdateUser func(childComplexity int, params model.UpdateUserInput) int VerifyEmail func(childComplexity int, params model.VerifyEmailInput) int } @@ -93,16 +92,23 @@ type ComplexityRoot struct { } User struct { - CreatedAt func(childComplexity int) int - Email func(childComplexity int) int - EmailVerifiedAt func(childComplexity int) int - FirstName func(childComplexity int) int - ID func(childComplexity int) int - Image func(childComplexity int) int - LastName func(childComplexity int) int - Roles func(childComplexity int) int - SignupMethod func(childComplexity int) int - UpdatedAt func(childComplexity int) int + Birthdate func(childComplexity int) int + CreatedAt func(childComplexity int) int + Email func(childComplexity int) int + EmailVerified func(childComplexity int) int + FamilyName func(childComplexity int) int + Gender func(childComplexity int) int + GivenName func(childComplexity int) int + ID func(childComplexity int) int + MiddleName func(childComplexity int) int + Nickname func(childComplexity int) int + PhoneNumber func(childComplexity int) int + PhoneNumberVerified func(childComplexity int) int + Picture func(childComplexity int) int + PreferredUsername func(childComplexity int) int + Roles func(childComplexity int) int + SignupMethods func(childComplexity int) int + UpdatedAt func(childComplexity int) int } VerificationRequest struct { @@ -119,21 +125,21 @@ type ComplexityRoot struct { type MutationResolver interface { Signup(ctx context.Context, params model.SignUpInput) (*model.AuthResponse, error) Login(ctx context.Context, params model.LoginInput) (*model.AuthResponse, error) - MagicLogin(ctx context.Context, params model.MagicLoginInput) (*model.Response, error) + MagicLinkLogin(ctx context.Context, params model.MagicLinkLoginInput) (*model.Response, error) Logout(ctx context.Context) (*model.Response, error) UpdateProfile(ctx context.Context, params model.UpdateProfileInput) (*model.Response, error) - AdminUpdateUser(ctx context.Context, params model.AdminUpdateUserInput) (*model.User, error) VerifyEmail(ctx context.Context, params model.VerifyEmailInput) (*model.AuthResponse, error) ResendVerifyEmail(ctx context.Context, params model.ResendVerifyEmailInput) (*model.Response, error) ForgotPassword(ctx context.Context, params model.ForgotPasswordInput) (*model.Response, error) ResetPassword(ctx context.Context, params model.ResetPasswordInput) (*model.Response, error) DeleteUser(ctx context.Context, params model.DeleteUserInput) (*model.Response, error) + UpdateUser(ctx context.Context, params model.UpdateUserInput) (*model.User, error) } type QueryResolver interface { Meta(ctx context.Context) (*model.Meta, error) - Users(ctx context.Context) ([]*model.User, error) Token(ctx context.Context, roles []string) (*model.AuthResponse, error) Profile(ctx context.Context) (*model.User, error) + Users(ctx context.Context) ([]*model.User, error) VerificationRequests(ctx context.Context) ([]*model.VerificationRequest, error) } @@ -152,19 +158,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { - case "AuthResponse.accessToken": + case "AuthResponse.access_token": if e.complexity.AuthResponse.AccessToken == nil { break } return e.complexity.AuthResponse.AccessToken(childComplexity), true - case "AuthResponse.accessTokenExpiresAt": - if e.complexity.AuthResponse.AccessTokenExpiresAt == nil { + case "AuthResponse.expires_at": + if e.complexity.AuthResponse.ExpiresAt == nil { break } - return e.complexity.AuthResponse.AccessTokenExpiresAt(childComplexity), true + return e.complexity.AuthResponse.ExpiresAt(childComplexity), true case "AuthResponse.message": if e.complexity.AuthResponse.Message == nil { @@ -194,54 +200,47 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Error.Reason(childComplexity), true - case "Meta.isBasicAuthenticationEnabled": + case "Meta.is_basic_authentication_enabled": if e.complexity.Meta.IsBasicAuthenticationEnabled == nil { break } return e.complexity.Meta.IsBasicAuthenticationEnabled(childComplexity), true - case "Meta.isEmailVerificationEnabled": + case "Meta.is_email_verification_enabled": if e.complexity.Meta.IsEmailVerificationEnabled == nil { break } return e.complexity.Meta.IsEmailVerificationEnabled(childComplexity), true - case "Meta.isFacebookLoginEnabled": + case "Meta.is_facebook_login_enabled": if e.complexity.Meta.IsFacebookLoginEnabled == nil { break } return e.complexity.Meta.IsFacebookLoginEnabled(childComplexity), true - case "Meta.isGithubLoginEnabled": + case "Meta.is_github_login_enabled": if e.complexity.Meta.IsGithubLoginEnabled == nil { break } return e.complexity.Meta.IsGithubLoginEnabled(childComplexity), true - case "Meta.isGoogleLoginEnabled": + case "Meta.is_google_login_enabled": if e.complexity.Meta.IsGoogleLoginEnabled == nil { break } return e.complexity.Meta.IsGoogleLoginEnabled(childComplexity), true - case "Meta.isMagicLoginEnabled": - if e.complexity.Meta.IsMagicLoginEnabled == nil { + case "Meta.is_magic_link_login_enabled": + if e.complexity.Meta.IsMagicLinkLoginEnabled == nil { break } - return e.complexity.Meta.IsMagicLoginEnabled(childComplexity), true - - case "Meta.isTwitterLoginEnabled": - if e.complexity.Meta.IsTwitterLoginEnabled == nil { - break - } - - return e.complexity.Meta.IsTwitterLoginEnabled(childComplexity), true + return e.complexity.Meta.IsMagicLinkLoginEnabled(childComplexity), true case "Meta.version": if e.complexity.Meta.Version == nil { @@ -250,36 +249,24 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Meta.Version(childComplexity), true - case "Mutation.adminUpdateUser": - if e.complexity.Mutation.AdminUpdateUser == nil { - break - } - - args, err := ec.field_Mutation_adminUpdateUser_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Mutation.AdminUpdateUser(childComplexity, args["params"].(model.AdminUpdateUserInput)), true - - case "Mutation.deleteUser": + case "Mutation._delete_user": if e.complexity.Mutation.DeleteUser == nil { break } - args, err := ec.field_Mutation_deleteUser_args(context.TODO(), rawArgs) + args, err := ec.field_Mutation__delete_user_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Mutation.DeleteUser(childComplexity, args["params"].(model.DeleteUserInput)), true - case "Mutation.forgotPassword": + case "Mutation.forgot_password": if e.complexity.Mutation.ForgotPassword == nil { break } - args, err := ec.field_Mutation_forgotPassword_args(context.TODO(), rawArgs) + args, err := ec.field_Mutation_forgot_password_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -305,36 +292,36 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.Logout(childComplexity), true - case "Mutation.magicLogin": - if e.complexity.Mutation.MagicLogin == nil { + case "Mutation.magic_link_login": + if e.complexity.Mutation.MagicLinkLogin == nil { break } - args, err := ec.field_Mutation_magicLogin_args(context.TODO(), rawArgs) + args, err := ec.field_Mutation_magic_link_login_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Mutation.MagicLogin(childComplexity, args["params"].(model.MagicLoginInput)), true + return e.complexity.Mutation.MagicLinkLogin(childComplexity, args["params"].(model.MagicLinkLoginInput)), true - case "Mutation.resendVerifyEmail": + case "Mutation.resend_verify_email": if e.complexity.Mutation.ResendVerifyEmail == nil { break } - args, err := ec.field_Mutation_resendVerifyEmail_args(context.TODO(), rawArgs) + args, err := ec.field_Mutation_resend_verify_email_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Mutation.ResendVerifyEmail(childComplexity, args["params"].(model.ResendVerifyEmailInput)), true - case "Mutation.resetPassword": + case "Mutation.reset_password": if e.complexity.Mutation.ResetPassword == nil { break } - args, err := ec.field_Mutation_resetPassword_args(context.TODO(), rawArgs) + args, err := ec.field_Mutation_reset_password_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -353,24 +340,36 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.Signup(childComplexity, args["params"].(model.SignUpInput)), true - case "Mutation.updateProfile": + case "Mutation.update_profile": if e.complexity.Mutation.UpdateProfile == nil { break } - args, err := ec.field_Mutation_updateProfile_args(context.TODO(), rawArgs) + args, err := ec.field_Mutation_update_profile_args(context.TODO(), rawArgs) if err != nil { return 0, false } return e.complexity.Mutation.UpdateProfile(childComplexity, args["params"].(model.UpdateProfileInput)), true - case "Mutation.verifyEmail": + case "Mutation._update_user": + if e.complexity.Mutation.UpdateUser == nil { + break + } + + args, err := ec.field_Mutation__update_user_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.UpdateUser(childComplexity, args["params"].(model.UpdateUserInput)), true + + case "Mutation.verify_email": if e.complexity.Mutation.VerifyEmail == nil { break } - args, err := ec.field_Mutation_verifyEmail_args(context.TODO(), rawArgs) + args, err := ec.field_Mutation_verify_email_args(context.TODO(), rawArgs) if err != nil { return 0, false } @@ -403,14 +402,14 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Token(childComplexity, args["roles"].([]string)), true - case "Query.users": + case "Query._users": if e.complexity.Query.Users == nil { break } return e.complexity.Query.Users(childComplexity), true - case "Query.verificationRequests": + case "Query._verification_requests": if e.complexity.Query.VerificationRequests == nil { break } @@ -424,7 +423,14 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Response.Message(childComplexity), true - case "User.createdAt": + case "User.birthdate": + if e.complexity.User.Birthdate == nil { + break + } + + return e.complexity.User.Birthdate(childComplexity), true + + case "User.created_at": if e.complexity.User.CreatedAt == nil { break } @@ -438,19 +444,33 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.Email(childComplexity), true - case "User.emailVerifiedAt": - if e.complexity.User.EmailVerifiedAt == nil { + case "User.email_verified": + if e.complexity.User.EmailVerified == nil { break } - return e.complexity.User.EmailVerifiedAt(childComplexity), true + return e.complexity.User.EmailVerified(childComplexity), true - case "User.firstName": - if e.complexity.User.FirstName == nil { + case "User.family_name": + if e.complexity.User.FamilyName == nil { break } - return e.complexity.User.FirstName(childComplexity), true + return e.complexity.User.FamilyName(childComplexity), true + + case "User.gender": + if e.complexity.User.Gender == nil { + break + } + + return e.complexity.User.Gender(childComplexity), true + + case "User.given_name": + if e.complexity.User.GivenName == nil { + break + } + + return e.complexity.User.GivenName(childComplexity), true case "User.id": if e.complexity.User.ID == nil { @@ -459,19 +479,47 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.ID(childComplexity), true - case "User.image": - if e.complexity.User.Image == nil { + case "User.middle_name": + if e.complexity.User.MiddleName == nil { break } - return e.complexity.User.Image(childComplexity), true + return e.complexity.User.MiddleName(childComplexity), true - case "User.lastName": - if e.complexity.User.LastName == nil { + case "User.nickname": + if e.complexity.User.Nickname == nil { break } - return e.complexity.User.LastName(childComplexity), true + return e.complexity.User.Nickname(childComplexity), true + + case "User.phone_number": + if e.complexity.User.PhoneNumber == nil { + break + } + + return e.complexity.User.PhoneNumber(childComplexity), true + + case "User.phone_number_verified": + if e.complexity.User.PhoneNumberVerified == nil { + break + } + + return e.complexity.User.PhoneNumberVerified(childComplexity), true + + case "User.picture": + if e.complexity.User.Picture == nil { + break + } + + return e.complexity.User.Picture(childComplexity), true + + case "User.preferred_username": + if e.complexity.User.PreferredUsername == nil { + break + } + + return e.complexity.User.PreferredUsername(childComplexity), true case "User.roles": if e.complexity.User.Roles == nil { @@ -480,21 +528,21 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.User.Roles(childComplexity), true - case "User.signupMethod": - if e.complexity.User.SignupMethod == nil { + case "User.signup_methods": + if e.complexity.User.SignupMethods == nil { break } - return e.complexity.User.SignupMethod(childComplexity), true + return e.complexity.User.SignupMethods(childComplexity), true - case "User.updatedAt": + case "User.updated_at": if e.complexity.User.UpdatedAt == nil { break } return e.complexity.User.UpdatedAt(childComplexity), true - case "VerificationRequest.createdAt": + case "VerificationRequest.created_at": if e.complexity.VerificationRequest.CreatedAt == nil { break } @@ -536,7 +584,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.VerificationRequest.Token(childComplexity), true - case "VerificationRequest.updatedAt": + case "VerificationRequest.updated_at": if e.complexity.VerificationRequest.UpdatedAt == nil { break } @@ -616,26 +664,33 @@ scalar Any type Meta { version: String! - isGoogleLoginEnabled: Boolean! - isFacebookLoginEnabled: Boolean! - isTwitterLoginEnabled: Boolean! - isGithubLoginEnabled: Boolean! - isEmailVerificationEnabled: Boolean! - isBasicAuthenticationEnabled: Boolean! - isMagicLoginEnabled: Boolean! + is_google_login_enabled: Boolean! + is_facebook_login_enabled: Boolean! + is_github_login_enabled: Boolean! + is_email_verification_enabled: Boolean! + is_basic_authentication_enabled: Boolean! + is_magic_link_login_enabled: Boolean! } type User { id: ID! email: String! - signupMethod: String! - firstName: String - lastName: String - emailVerifiedAt: Int64 - image: String - createdAt: Int64 - updatedAt: Int64 + email_verified: Boolean! + signup_methods: String! + given_name: String + family_name: String + middle_name: String + nickname: String + # defaults to email + preferred_username: String + gender: String + birthdate: String + phone_number: String + phone_number_verified: Boolean + picture: String roles: [String!]! + created_at: Int64 + updated_at: Int64 } type VerificationRequest { @@ -644,8 +699,8 @@ type VerificationRequest { token: String email: String expires: Int64 - createdAt: Int64 - updatedAt: Int64 + created_at: Int64 + updated_at: Int64 } type Error { @@ -655,8 +710,8 @@ type Error { type AuthResponse { message: String! - accessToken: String - accessTokenExpiresAt: Int64 + access_token: String + expires_at: Int64 user: User } @@ -665,12 +720,17 @@ type Response { } input SignUpInput { - firstName: String - lastName: String email: String! + given_name: String + family_name: String + middle_name: String + nickname: String + gender: String + birthdate: String + phone_number: String + picture: String password: String! - confirmPassword: String! - image: String + confirm_password: String! roles: [String!] } @@ -689,22 +749,31 @@ input ResendVerifyEmailInput { } input UpdateProfileInput { - oldPassword: String - newPassword: String - confirmNewPassword: String - firstName: String - lastName: String - image: String + old_password: String + new_password: String + confirm_new_password: String email: String - # roles: [String] + given_name: String + family_name: String + middle_name: String + nickname: String + gender: String + birthdate: String + phone_number: String + picture: String } -input AdminUpdateUserInput { +input UpdateUserInput { id: ID! email: String - firstName: String - lastName: String - image: String + given_name: String + family_name: String + middle_name: String + nickname: String + gender: String + birthdate: String + phone_number: String + picture: String roles: [String] } @@ -715,14 +784,14 @@ input ForgotPasswordInput { input ResetPasswordInput { token: String! password: String! - confirmPassword: String! + confirm_password: String! } input DeleteUserInput { email: String! } -input MagicLoginInput { +input MagicLinkLoginInput { email: String! roles: [String!] } @@ -730,23 +799,25 @@ input MagicLoginInput { type Mutation { signup(params: SignUpInput!): AuthResponse! login(params: LoginInput!): AuthResponse! - magicLogin(params: MagicLoginInput!): Response! + magic_link_login(params: MagicLinkLoginInput!): Response! logout: Response! - updateProfile(params: UpdateProfileInput!): Response! - adminUpdateUser(params: AdminUpdateUserInput!): User! - verifyEmail(params: VerifyEmailInput!): AuthResponse! - resendVerifyEmail(params: ResendVerifyEmailInput!): Response! - forgotPassword(params: ForgotPasswordInput!): Response! - resetPassword(params: ResetPasswordInput!): Response! - deleteUser(params: DeleteUserInput!): Response! + update_profile(params: UpdateProfileInput!): Response! + verify_email(params: VerifyEmailInput!): AuthResponse! + resend_verify_email(params: ResendVerifyEmailInput!): Response! + forgot_password(params: ForgotPasswordInput!): Response! + reset_password(params: ResetPasswordInput!): Response! + # admin only apis + _delete_user(params: DeleteUserInput!): Response! + _update_user(params: UpdateUserInput!): User! } type Query { meta: Meta! - users: [User!]! token(roles: [String!]): AuthResponse profile: User! - verificationRequests: [VerificationRequest!]! + # admin only apis + _users: [User!]! + _verification_requests: [VerificationRequest!]! } `, BuiltIn: false}, } @@ -756,22 +827,7 @@ var parsedSchema = gqlparser.MustLoadSchema(sources...) // region ***************************** args.gotpl ***************************** -func (ec *executionContext) field_Mutation_adminUpdateUser_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 model.AdminUpdateUserInput - if tmp, ok := rawArgs["params"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params")) - arg0, err = ec.unmarshalNAdminUpdateUserInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐAdminUpdateUserInput(ctx, tmp) - if err != nil { - return nil, err - } - } - args["params"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_deleteUser_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Mutation__delete_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 model.DeleteUserInput @@ -786,7 +842,22 @@ func (ec *executionContext) field_Mutation_deleteUser_args(ctx context.Context, return args, nil } -func (ec *executionContext) field_Mutation_forgotPassword_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Mutation__update_user_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.UpdateUserInput + if tmp, ok := rawArgs["params"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params")) + arg0, err = ec.unmarshalNUpdateUserInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐUpdateUserInput(ctx, tmp) + if err != nil { + return nil, err + } + } + args["params"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Mutation_forgot_password_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 model.ForgotPasswordInput @@ -816,13 +887,13 @@ func (ec *executionContext) field_Mutation_login_args(ctx context.Context, rawAr return args, nil } -func (ec *executionContext) field_Mutation_magicLogin_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Mutation_magic_link_login_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 model.MagicLoginInput + var arg0 model.MagicLinkLoginInput if tmp, ok := rawArgs["params"]; ok { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params")) - arg0, err = ec.unmarshalNMagicLoginInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐMagicLoginInput(ctx, tmp) + arg0, err = ec.unmarshalNMagicLinkLoginInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐMagicLinkLoginInput(ctx, tmp) if err != nil { return nil, err } @@ -831,7 +902,7 @@ func (ec *executionContext) field_Mutation_magicLogin_args(ctx context.Context, return args, nil } -func (ec *executionContext) field_Mutation_resendVerifyEmail_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Mutation_resend_verify_email_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 model.ResendVerifyEmailInput @@ -846,7 +917,7 @@ func (ec *executionContext) field_Mutation_resendVerifyEmail_args(ctx context.Co return args, nil } -func (ec *executionContext) field_Mutation_resetPassword_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Mutation_reset_password_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 model.ResetPasswordInput @@ -876,7 +947,7 @@ func (ec *executionContext) field_Mutation_signup_args(ctx context.Context, rawA return args, nil } -func (ec *executionContext) field_Mutation_updateProfile_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Mutation_update_profile_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 model.UpdateProfileInput @@ -891,7 +962,7 @@ func (ec *executionContext) field_Mutation_updateProfile_args(ctx context.Contex return args, nil } -func (ec *executionContext) field_Mutation_verifyEmail_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Mutation_verify_email_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 model.VerifyEmailInput @@ -1009,7 +1080,7 @@ func (ec *executionContext) _AuthResponse_message(ctx context.Context, field gra return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _AuthResponse_accessToken(ctx context.Context, field graphql.CollectedField, obj *model.AuthResponse) (ret graphql.Marshaler) { +func (ec *executionContext) _AuthResponse_access_token(ctx context.Context, field graphql.CollectedField, obj *model.AuthResponse) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -1041,7 +1112,7 @@ func (ec *executionContext) _AuthResponse_accessToken(ctx context.Context, field return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _AuthResponse_accessTokenExpiresAt(ctx context.Context, field graphql.CollectedField, obj *model.AuthResponse) (ret graphql.Marshaler) { +func (ec *executionContext) _AuthResponse_expires_at(ctx context.Context, field graphql.CollectedField, obj *model.AuthResponse) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -1059,7 +1130,7 @@ func (ec *executionContext) _AuthResponse_accessTokenExpiresAt(ctx context.Conte 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.AccessTokenExpiresAt, nil + return obj.ExpiresAt, nil }) if err != nil { ec.Error(ctx, err) @@ -1210,7 +1281,7 @@ func (ec *executionContext) _Meta_version(ctx context.Context, field graphql.Col return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Meta_isGoogleLoginEnabled(ctx context.Context, field graphql.CollectedField, obj *model.Meta) (ret graphql.Marshaler) { +func (ec *executionContext) _Meta_is_google_login_enabled(ctx context.Context, field graphql.CollectedField, obj *model.Meta) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -1245,7 +1316,7 @@ func (ec *executionContext) _Meta_isGoogleLoginEnabled(ctx context.Context, fiel return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Meta_isFacebookLoginEnabled(ctx context.Context, field graphql.CollectedField, obj *model.Meta) (ret graphql.Marshaler) { +func (ec *executionContext) _Meta_is_facebook_login_enabled(ctx context.Context, field graphql.CollectedField, obj *model.Meta) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -1280,42 +1351,7 @@ func (ec *executionContext) _Meta_isFacebookLoginEnabled(ctx context.Context, fi return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Meta_isTwitterLoginEnabled(ctx context.Context, field graphql.CollectedField, obj *model.Meta) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Meta", - 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.IsTwitterLoginEnabled, 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) _Meta_isGithubLoginEnabled(ctx context.Context, field graphql.CollectedField, obj *model.Meta) (ret graphql.Marshaler) { +func (ec *executionContext) _Meta_is_github_login_enabled(ctx context.Context, field graphql.CollectedField, obj *model.Meta) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -1350,7 +1386,7 @@ func (ec *executionContext) _Meta_isGithubLoginEnabled(ctx context.Context, fiel return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Meta_isEmailVerificationEnabled(ctx context.Context, field graphql.CollectedField, obj *model.Meta) (ret graphql.Marshaler) { +func (ec *executionContext) _Meta_is_email_verification_enabled(ctx context.Context, field graphql.CollectedField, obj *model.Meta) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -1385,7 +1421,7 @@ func (ec *executionContext) _Meta_isEmailVerificationEnabled(ctx context.Context return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Meta_isBasicAuthenticationEnabled(ctx context.Context, field graphql.CollectedField, obj *model.Meta) (ret graphql.Marshaler) { +func (ec *executionContext) _Meta_is_basic_authentication_enabled(ctx context.Context, field graphql.CollectedField, obj *model.Meta) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -1420,7 +1456,7 @@ func (ec *executionContext) _Meta_isBasicAuthenticationEnabled(ctx context.Conte return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) _Meta_isMagicLoginEnabled(ctx context.Context, field graphql.CollectedField, obj *model.Meta) (ret graphql.Marshaler) { +func (ec *executionContext) _Meta_is_magic_link_login_enabled(ctx context.Context, field graphql.CollectedField, obj *model.Meta) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -1438,7 +1474,7 @@ func (ec *executionContext) _Meta_isMagicLoginEnabled(ctx context.Context, field 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.IsMagicLoginEnabled, nil + return obj.IsMagicLinkLoginEnabled, nil }) if err != nil { ec.Error(ctx, err) @@ -1539,7 +1575,7 @@ func (ec *executionContext) _Mutation_login(ctx context.Context, field graphql.C return ec.marshalNAuthResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐAuthResponse(ctx, field.Selections, res) } -func (ec *executionContext) _Mutation_magicLogin(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_magic_link_login(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -1556,7 +1592,7 @@ func (ec *executionContext) _Mutation_magicLogin(ctx context.Context, field grap ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_magicLogin_args(ctx, rawArgs) + args, err := ec.field_Mutation_magic_link_login_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -1564,7 +1600,7 @@ func (ec *executionContext) _Mutation_magicLogin(ctx context.Context, field grap 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().MagicLogin(rctx, args["params"].(model.MagicLoginInput)) + return ec.resolvers.Mutation().MagicLinkLogin(rctx, args["params"].(model.MagicLinkLoginInput)) }) if err != nil { ec.Error(ctx, err) @@ -1616,7 +1652,7 @@ func (ec *executionContext) _Mutation_logout(ctx context.Context, field graphql. return ec.marshalNResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐResponse(ctx, field.Selections, res) } -func (ec *executionContext) _Mutation_updateProfile(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_update_profile(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -1633,7 +1669,7 @@ func (ec *executionContext) _Mutation_updateProfile(ctx context.Context, field g ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_updateProfile_args(ctx, rawArgs) + args, err := ec.field_Mutation_update_profile_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -1658,7 +1694,7 @@ func (ec *executionContext) _Mutation_updateProfile(ctx context.Context, field g return ec.marshalNResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐResponse(ctx, field.Selections, res) } -func (ec *executionContext) _Mutation_adminUpdateUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_verify_email(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -1675,49 +1711,7 @@ func (ec *executionContext) _Mutation_adminUpdateUser(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_adminUpdateUser_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - 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().AdminUpdateUser(rctx, args["params"].(model.AdminUpdateUserInput)) - }) - 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.(*model.User) - fc.Result = res - return ec.marshalNUser2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) -} - -func (ec *executionContext) _Mutation_verifyEmail(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: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - IsResolver: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_verifyEmail_args(ctx, rawArgs) + args, err := ec.field_Mutation_verify_email_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -1742,7 +1736,7 @@ func (ec *executionContext) _Mutation_verifyEmail(ctx context.Context, field gra return ec.marshalNAuthResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐAuthResponse(ctx, field.Selections, res) } -func (ec *executionContext) _Mutation_resendVerifyEmail(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_resend_verify_email(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -1759,7 +1753,7 @@ func (ec *executionContext) _Mutation_resendVerifyEmail(ctx context.Context, fie ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_resendVerifyEmail_args(ctx, rawArgs) + args, err := ec.field_Mutation_resend_verify_email_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -1784,7 +1778,7 @@ func (ec *executionContext) _Mutation_resendVerifyEmail(ctx context.Context, fie return ec.marshalNResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐResponse(ctx, field.Selections, res) } -func (ec *executionContext) _Mutation_forgotPassword(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_forgot_password(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -1801,7 +1795,7 @@ func (ec *executionContext) _Mutation_forgotPassword(ctx context.Context, field ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_forgotPassword_args(ctx, rawArgs) + args, err := ec.field_Mutation_forgot_password_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -1826,7 +1820,7 @@ func (ec *executionContext) _Mutation_forgotPassword(ctx context.Context, field return ec.marshalNResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐResponse(ctx, field.Selections, res) } -func (ec *executionContext) _Mutation_resetPassword(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_reset_password(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -1843,7 +1837,7 @@ func (ec *executionContext) _Mutation_resetPassword(ctx context.Context, field g ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_resetPassword_args(ctx, rawArgs) + args, err := ec.field_Mutation_reset_password_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -1868,7 +1862,7 @@ func (ec *executionContext) _Mutation_resetPassword(ctx context.Context, field g return ec.marshalNResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐResponse(ctx, field.Selections, res) } -func (ec *executionContext) _Mutation_deleteUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation__delete_user(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -1885,7 +1879,7 @@ func (ec *executionContext) _Mutation_deleteUser(ctx context.Context, field grap ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_deleteUser_args(ctx, rawArgs) + args, err := ec.field_Mutation__delete_user_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -1910,6 +1904,48 @@ func (ec *executionContext) _Mutation_deleteUser(ctx context.Context, field grap return ec.marshalNResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐResponse(ctx, field.Selections, res) } +func (ec *executionContext) _Mutation__update_user(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: "Mutation", + Field: field, + Args: nil, + IsMethod: true, + IsResolver: true, + } + + ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation__update_user_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + 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().UpdateUser(rctx, args["params"].(model.UpdateUserInput)) + }) + 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.(*model.User) + fc.Result = res + return ec.marshalNUser2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) +} + func (ec *executionContext) _Query_meta(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -1945,41 +1981,6 @@ func (ec *executionContext) _Query_meta(ctx context.Context, field graphql.Colle return ec.marshalNMeta2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐMeta(ctx, field.Selections, res) } -func (ec *executionContext) _Query_users(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().Users(rctx) - }) - 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.([]*model.User) - fc.Result = res - return ec.marshalNUser2ᚕᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐUserᚄ(ctx, field.Selections, res) -} - func (ec *executionContext) _Query_token(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -2054,7 +2055,42 @@ func (ec *executionContext) _Query_profile(ctx context.Context, field graphql.Co return ec.marshalNUser2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) _Query_verificationRequests(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query__users(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().Users(rctx) + }) + 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.([]*model.User) + fc.Result = res + return ec.marshalNUser2ᚕᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐUserᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) _Query__verification_requests(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -2265,7 +2301,7 @@ func (ec *executionContext) _User_email(ctx context.Context, field graphql.Colle return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _User_signupMethod(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { +func (ec *executionContext) _User_email_verified(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -2283,7 +2319,42 @@ func (ec *executionContext) _User_signupMethod(ctx context.Context, field graphq 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.SignupMethod, nil + return obj.EmailVerified, 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) _User_signup_methods(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "User", + 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.SignupMethods, nil }) if err != nil { ec.Error(ctx, err) @@ -2300,7 +2371,7 @@ func (ec *executionContext) _User_signupMethod(ctx context.Context, field graphq return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _User_firstName(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { +func (ec *executionContext) _User_given_name(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -2318,7 +2389,7 @@ func (ec *executionContext) _User_firstName(ctx context.Context, field graphql.C 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.FirstName, nil + return obj.GivenName, nil }) if err != nil { ec.Error(ctx, err) @@ -2332,7 +2403,7 @@ func (ec *executionContext) _User_firstName(ctx context.Context, field graphql.C return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _User_lastName(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { +func (ec *executionContext) _User_family_name(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -2350,7 +2421,7 @@ func (ec *executionContext) _User_lastName(ctx context.Context, field graphql.Co 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.LastName, nil + return obj.FamilyName, nil }) if err != nil { ec.Error(ctx, err) @@ -2364,7 +2435,7 @@ func (ec *executionContext) _User_lastName(ctx context.Context, field graphql.Co return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _User_emailVerifiedAt(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { +func (ec *executionContext) _User_middle_name(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -2382,39 +2453,7 @@ func (ec *executionContext) _User_emailVerifiedAt(ctx context.Context, field gra 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.EmailVerifiedAt, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*int64) - fc.Result = res - return ec.marshalOInt642ᚖint64(ctx, field.Selections, res) -} - -func (ec *executionContext) _User_image(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "User", - 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.Image, nil + return obj.MiddleName, nil }) if err != nil { ec.Error(ctx, err) @@ -2428,7 +2467,7 @@ func (ec *executionContext) _User_image(ctx context.Context, field graphql.Colle return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _User_createdAt(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { +func (ec *executionContext) _User_nickname(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -2446,7 +2485,7 @@ func (ec *executionContext) _User_createdAt(ctx context.Context, field graphql.C 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.CreatedAt, nil + return obj.Nickname, nil }) if err != nil { ec.Error(ctx, err) @@ -2455,12 +2494,12 @@ func (ec *executionContext) _User_createdAt(ctx context.Context, field graphql.C if resTmp == nil { return graphql.Null } - res := resTmp.(*int64) + res := resTmp.(*string) fc.Result = res - return ec.marshalOInt642ᚖint64(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) _User_updatedAt(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { +func (ec *executionContext) _User_preferred_username(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -2478,7 +2517,7 @@ func (ec *executionContext) _User_updatedAt(ctx context.Context, field graphql.C 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.UpdatedAt, nil + return obj.PreferredUsername, nil }) if err != nil { ec.Error(ctx, err) @@ -2487,9 +2526,169 @@ func (ec *executionContext) _User_updatedAt(ctx context.Context, field graphql.C if resTmp == nil { return graphql.Null } - res := resTmp.(*int64) + res := resTmp.(*string) fc.Result = res - return ec.marshalOInt642ᚖint64(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _User_gender(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "User", + 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.Gender, 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) _User_birthdate(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "User", + 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.Birthdate, 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) _User_phone_number(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "User", + 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.PhoneNumber, 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) _User_phone_number_verified(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "User", + 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.PhoneNumberVerified, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*bool) + fc.Result = res + return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) +} + +func (ec *executionContext) _User_picture(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "User", + 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.Picture, 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) _User_roles(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { @@ -2527,6 +2726,70 @@ func (ec *executionContext) _User_roles(ctx context.Context, field graphql.Colle return ec.marshalNString2ᚕstringᚄ(ctx, field.Selections, res) } +func (ec *executionContext) _User_created_at(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "User", + 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.CreatedAt, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*int64) + fc.Result = res + return ec.marshalOInt642ᚖint64(ctx, field.Selections, res) +} + +func (ec *executionContext) _User_updated_at(ctx context.Context, field graphql.CollectedField, obj *model.User) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "User", + 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.UpdatedAt, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*int64) + fc.Result = res + return ec.marshalOInt642ᚖint64(ctx, field.Selections, res) +} + func (ec *executionContext) _VerificationRequest_id(ctx context.Context, field graphql.CollectedField, obj *model.VerificationRequest) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -2690,7 +2953,7 @@ func (ec *executionContext) _VerificationRequest_expires(ctx context.Context, fi return ec.marshalOInt642ᚖint64(ctx, field.Selections, res) } -func (ec *executionContext) _VerificationRequest_createdAt(ctx context.Context, field graphql.CollectedField, obj *model.VerificationRequest) (ret graphql.Marshaler) { +func (ec *executionContext) _VerificationRequest_created_at(ctx context.Context, field graphql.CollectedField, obj *model.VerificationRequest) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -2722,7 +2985,7 @@ func (ec *executionContext) _VerificationRequest_createdAt(ctx context.Context, return ec.marshalOInt642ᚖint64(ctx, field.Selections, res) } -func (ec *executionContext) _VerificationRequest_updatedAt(ctx context.Context, field graphql.CollectedField, obj *model.VerificationRequest) (ret graphql.Marshaler) { +func (ec *executionContext) _VerificationRequest_updated_at(ctx context.Context, field graphql.CollectedField, obj *model.VerificationRequest) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -2891,6 +3154,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) } +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "__Directive", + 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.IsRepeatable, 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) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -3841,69 +4139,12 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co // region **************************** input.gotpl ***************************** -func (ec *executionContext) unmarshalInputAdminUpdateUserInput(ctx context.Context, obj interface{}) (model.AdminUpdateUserInput, error) { - var it model.AdminUpdateUserInput - var asMap = obj.(map[string]interface{}) - - for k, v := range asMap { - switch k { - case "id": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - it.ID, err = ec.unmarshalNID2string(ctx, v) - if err != nil { - return it, err - } - case "email": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email")) - it.Email, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - case "firstName": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("firstName")) - it.FirstName, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - case "lastName": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastName")) - it.LastName, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - case "image": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("image")) - it.Image, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - case "roles": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("roles")) - it.Roles, err = ec.unmarshalOString2ᚕᚖstring(ctx, v) - if err != nil { - return it, err - } - } - } - - return it, nil -} - func (ec *executionContext) unmarshalInputDeleteUserInput(ctx context.Context, obj interface{}) (model.DeleteUserInput, error) { var it model.DeleteUserInput - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { @@ -3923,7 +4164,10 @@ func (ec *executionContext) unmarshalInputDeleteUserInput(ctx context.Context, o func (ec *executionContext) unmarshalInputForgotPasswordInput(ctx context.Context, obj interface{}) (model.ForgotPasswordInput, error) { var it model.ForgotPasswordInput - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { @@ -3943,7 +4187,10 @@ func (ec *executionContext) unmarshalInputForgotPasswordInput(ctx context.Contex func (ec *executionContext) unmarshalInputLoginInput(ctx context.Context, obj interface{}) (model.LoginInput, error) { var it model.LoginInput - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { @@ -3977,9 +4224,12 @@ func (ec *executionContext) unmarshalInputLoginInput(ctx context.Context, obj in return it, nil } -func (ec *executionContext) unmarshalInputMagicLoginInput(ctx context.Context, obj interface{}) (model.MagicLoginInput, error) { - var it model.MagicLoginInput - var asMap = obj.(map[string]interface{}) +func (ec *executionContext) unmarshalInputMagicLinkLoginInput(ctx context.Context, obj interface{}) (model.MagicLinkLoginInput, error) { + var it model.MagicLinkLoginInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { @@ -4007,7 +4257,10 @@ func (ec *executionContext) unmarshalInputMagicLoginInput(ctx context.Context, o func (ec *executionContext) unmarshalInputResendVerifyEmailInput(ctx context.Context, obj interface{}) (model.ResendVerifyEmailInput, error) { var it model.ResendVerifyEmailInput - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { @@ -4027,7 +4280,10 @@ func (ec *executionContext) unmarshalInputResendVerifyEmailInput(ctx context.Con func (ec *executionContext) unmarshalInputResetPasswordInput(ctx context.Context, obj interface{}) (model.ResetPasswordInput, error) { var it model.ResetPasswordInput - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { @@ -4047,10 +4303,10 @@ func (ec *executionContext) unmarshalInputResetPasswordInput(ctx context.Context if err != nil { return it, err } - case "confirmPassword": + case "confirm_password": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("confirmPassword")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("confirm_password")) it.ConfirmPassword, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err @@ -4063,26 +4319,13 @@ func (ec *executionContext) unmarshalInputResetPasswordInput(ctx context.Context func (ec *executionContext) unmarshalInputSignUpInput(ctx context.Context, obj interface{}) (model.SignUpInput, error) { var it model.SignUpInput - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { - case "firstName": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("firstName")) - it.FirstName, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - case "lastName": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastName")) - it.LastName, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } case "email": var err error @@ -4091,6 +4334,70 @@ func (ec *executionContext) unmarshalInputSignUpInput(ctx context.Context, obj i if err != nil { return it, err } + case "given_name": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("given_name")) + it.GivenName, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "family_name": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("family_name")) + it.FamilyName, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "middle_name": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("middle_name")) + it.MiddleName, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "nickname": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nickname")) + it.Nickname, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "gender": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gender")) + it.Gender, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "birthdate": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("birthdate")) + it.Birthdate, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "phone_number": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("phone_number")) + it.PhoneNumber, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "picture": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("picture")) + it.Picture, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } case "password": var err error @@ -4099,22 +4406,14 @@ func (ec *executionContext) unmarshalInputSignUpInput(ctx context.Context, obj i if err != nil { return it, err } - case "confirmPassword": + case "confirm_password": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("confirmPassword")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("confirm_password")) it.ConfirmPassword, err = ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } - case "image": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("image")) - it.Image, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } case "roles": var err error @@ -4131,58 +4430,37 @@ func (ec *executionContext) unmarshalInputSignUpInput(ctx context.Context, obj i func (ec *executionContext) unmarshalInputUpdateProfileInput(ctx context.Context, obj interface{}) (model.UpdateProfileInput, error) { var it model.UpdateProfileInput - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { - case "oldPassword": + case "old_password": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("oldPassword")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("old_password")) it.OldPassword, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "newPassword": + case "new_password": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("newPassword")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("new_password")) it.NewPassword, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "confirmNewPassword": + case "confirm_new_password": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("confirmNewPassword")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("confirm_new_password")) it.ConfirmNewPassword, err = ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - case "firstName": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("firstName")) - it.FirstName, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - case "lastName": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastName")) - it.LastName, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - case "image": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("image")) - it.Image, err = ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } case "email": var err error @@ -4191,6 +4469,173 @@ func (ec *executionContext) unmarshalInputUpdateProfileInput(ctx context.Context if err != nil { return it, err } + case "given_name": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("given_name")) + it.GivenName, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "family_name": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("family_name")) + it.FamilyName, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "middle_name": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("middle_name")) + it.MiddleName, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "nickname": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nickname")) + it.Nickname, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "gender": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gender")) + it.Gender, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "birthdate": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("birthdate")) + it.Birthdate, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "phone_number": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("phone_number")) + it.PhoneNumber, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "picture": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("picture")) + it.Picture, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputUpdateUserInput(ctx context.Context, obj interface{}) (model.UpdateUserInput, error) { + var it model.UpdateUserInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + for k, v := range asMap { + switch k { + case "id": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + it.ID, err = ec.unmarshalNID2string(ctx, v) + if err != nil { + return it, err + } + case "email": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email")) + it.Email, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "given_name": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("given_name")) + it.GivenName, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "family_name": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("family_name")) + it.FamilyName, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "middle_name": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("middle_name")) + it.MiddleName, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "nickname": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nickname")) + it.Nickname, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "gender": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("gender")) + it.Gender, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "birthdate": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("birthdate")) + it.Birthdate, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "phone_number": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("phone_number")) + it.PhoneNumber, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "picture": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("picture")) + it.Picture, err = ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + case "roles": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("roles")) + it.Roles, err = ec.unmarshalOString2ᚕᚖstring(ctx, v) + if err != nil { + return it, err + } } } @@ -4199,7 +4644,10 @@ func (ec *executionContext) unmarshalInputUpdateProfileInput(ctx context.Context func (ec *executionContext) unmarshalInputVerifyEmailInput(ctx context.Context, obj interface{}) (model.VerifyEmailInput, error) { var it model.VerifyEmailInput - var asMap = obj.(map[string]interface{}) + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } for k, v := range asMap { switch k { @@ -4241,10 +4689,10 @@ func (ec *executionContext) _AuthResponse(ctx context.Context, sel ast.Selection if out.Values[i] == graphql.Null { invalids++ } - case "accessToken": - out.Values[i] = ec._AuthResponse_accessToken(ctx, field, obj) - case "accessTokenExpiresAt": - out.Values[i] = ec._AuthResponse_accessTokenExpiresAt(ctx, field, obj) + case "access_token": + out.Values[i] = ec._AuthResponse_access_token(ctx, field, obj) + case "expires_at": + out.Values[i] = ec._AuthResponse_expires_at(ctx, field, obj) case "user": out.Values[i] = ec._AuthResponse_user(ctx, field, obj) default: @@ -4306,38 +4754,33 @@ func (ec *executionContext) _Meta(ctx context.Context, sel ast.SelectionSet, obj if out.Values[i] == graphql.Null { invalids++ } - case "isGoogleLoginEnabled": - out.Values[i] = ec._Meta_isGoogleLoginEnabled(ctx, field, obj) + case "is_google_login_enabled": + out.Values[i] = ec._Meta_is_google_login_enabled(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } - case "isFacebookLoginEnabled": - out.Values[i] = ec._Meta_isFacebookLoginEnabled(ctx, field, obj) + case "is_facebook_login_enabled": + out.Values[i] = ec._Meta_is_facebook_login_enabled(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } - case "isTwitterLoginEnabled": - out.Values[i] = ec._Meta_isTwitterLoginEnabled(ctx, field, obj) + case "is_github_login_enabled": + out.Values[i] = ec._Meta_is_github_login_enabled(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } - case "isGithubLoginEnabled": - out.Values[i] = ec._Meta_isGithubLoginEnabled(ctx, field, obj) + case "is_email_verification_enabled": + out.Values[i] = ec._Meta_is_email_verification_enabled(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } - case "isEmailVerificationEnabled": - out.Values[i] = ec._Meta_isEmailVerificationEnabled(ctx, field, obj) + case "is_basic_authentication_enabled": + out.Values[i] = ec._Meta_is_basic_authentication_enabled(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } - case "isBasicAuthenticationEnabled": - out.Values[i] = ec._Meta_isBasicAuthenticationEnabled(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "isMagicLoginEnabled": - out.Values[i] = ec._Meta_isMagicLoginEnabled(ctx, field, obj) + case "is_magic_link_login_enabled": + out.Values[i] = ec._Meta_is_magic_link_login_enabled(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } @@ -4377,8 +4820,8 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { invalids++ } - case "magicLogin": - out.Values[i] = ec._Mutation_magicLogin(ctx, field) + case "magic_link_login": + out.Values[i] = ec._Mutation_magic_link_login(ctx, field) if out.Values[i] == graphql.Null { invalids++ } @@ -4387,38 +4830,38 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { invalids++ } - case "updateProfile": - out.Values[i] = ec._Mutation_updateProfile(ctx, field) + case "update_profile": + out.Values[i] = ec._Mutation_update_profile(ctx, field) if out.Values[i] == graphql.Null { invalids++ } - case "adminUpdateUser": - out.Values[i] = ec._Mutation_adminUpdateUser(ctx, field) + case "verify_email": + out.Values[i] = ec._Mutation_verify_email(ctx, field) if out.Values[i] == graphql.Null { invalids++ } - case "verifyEmail": - out.Values[i] = ec._Mutation_verifyEmail(ctx, field) + case "resend_verify_email": + out.Values[i] = ec._Mutation_resend_verify_email(ctx, field) if out.Values[i] == graphql.Null { invalids++ } - case "resendVerifyEmail": - out.Values[i] = ec._Mutation_resendVerifyEmail(ctx, field) + case "forgot_password": + out.Values[i] = ec._Mutation_forgot_password(ctx, field) if out.Values[i] == graphql.Null { invalids++ } - case "forgotPassword": - out.Values[i] = ec._Mutation_forgotPassword(ctx, field) + case "reset_password": + out.Values[i] = ec._Mutation_reset_password(ctx, field) if out.Values[i] == graphql.Null { invalids++ } - case "resetPassword": - out.Values[i] = ec._Mutation_resetPassword(ctx, field) + case "_delete_user": + out.Values[i] = ec._Mutation__delete_user(ctx, field) if out.Values[i] == graphql.Null { invalids++ } - case "deleteUser": - out.Values[i] = ec._Mutation_deleteUser(ctx, field) + case "_update_user": + out.Values[i] = ec._Mutation__update_user(ctx, field) if out.Values[i] == graphql.Null { invalids++ } @@ -4462,20 +4905,6 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } return res }) - case "users": - 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_users(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - }) case "token": field := field out.Concurrently(i, func() (res graphql.Marshaler) { @@ -4501,7 +4930,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } return res }) - case "verificationRequests": + case "_users": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { @@ -4509,7 +4938,21 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_verificationRequests(ctx, field) + res = ec._Query__users(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + return res + }) + case "_verification_requests": + 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__verification_requests(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } @@ -4578,28 +5021,45 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj if out.Values[i] == graphql.Null { invalids++ } - case "signupMethod": - out.Values[i] = ec._User_signupMethod(ctx, field, obj) + case "email_verified": + out.Values[i] = ec._User_email_verified(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } - case "firstName": - out.Values[i] = ec._User_firstName(ctx, field, obj) - case "lastName": - out.Values[i] = ec._User_lastName(ctx, field, obj) - case "emailVerifiedAt": - out.Values[i] = ec._User_emailVerifiedAt(ctx, field, obj) - case "image": - out.Values[i] = ec._User_image(ctx, field, obj) - case "createdAt": - out.Values[i] = ec._User_createdAt(ctx, field, obj) - case "updatedAt": - out.Values[i] = ec._User_updatedAt(ctx, field, obj) + case "signup_methods": + out.Values[i] = ec._User_signup_methods(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + case "given_name": + out.Values[i] = ec._User_given_name(ctx, field, obj) + case "family_name": + out.Values[i] = ec._User_family_name(ctx, field, obj) + case "middle_name": + out.Values[i] = ec._User_middle_name(ctx, field, obj) + case "nickname": + out.Values[i] = ec._User_nickname(ctx, field, obj) + case "preferred_username": + out.Values[i] = ec._User_preferred_username(ctx, field, obj) + case "gender": + out.Values[i] = ec._User_gender(ctx, field, obj) + case "birthdate": + out.Values[i] = ec._User_birthdate(ctx, field, obj) + case "phone_number": + out.Values[i] = ec._User_phone_number(ctx, field, obj) + case "phone_number_verified": + out.Values[i] = ec._User_phone_number_verified(ctx, field, obj) + case "picture": + out.Values[i] = ec._User_picture(ctx, field, obj) case "roles": out.Values[i] = ec._User_roles(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } + case "created_at": + out.Values[i] = ec._User_created_at(ctx, field, obj) + case "updated_at": + out.Values[i] = ec._User_updated_at(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -4635,10 +5095,10 @@ func (ec *executionContext) _VerificationRequest(ctx context.Context, sel ast.Se out.Values[i] = ec._VerificationRequest_email(ctx, field, obj) case "expires": out.Values[i] = ec._VerificationRequest_expires(ctx, field, obj) - case "createdAt": - out.Values[i] = ec._VerificationRequest_createdAt(ctx, field, obj) - case "updatedAt": - out.Values[i] = ec._VerificationRequest_updatedAt(ctx, field, obj) + case "created_at": + out.Values[i] = ec._VerificationRequest_created_at(ctx, field, obj) + case "updated_at": + out.Values[i] = ec._VerificationRequest_updated_at(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -4678,6 +5138,11 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS if out.Values[i] == graphql.Null { invalids++ } + case "isRepeatable": + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -4895,11 +5360,6 @@ func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, o // region ***************************** type.gotpl ***************************** -func (ec *executionContext) unmarshalNAdminUpdateUserInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐAdminUpdateUserInput(ctx context.Context, v interface{}) (model.AdminUpdateUserInput, error) { - res, err := ec.unmarshalInputAdminUpdateUserInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - func (ec *executionContext) marshalNAuthResponse2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐAuthResponse(ctx context.Context, sel ast.SelectionSet, v model.AuthResponse) graphql.Marshaler { return ec._AuthResponse(ctx, sel, &v) } @@ -4959,8 +5419,8 @@ func (ec *executionContext) unmarshalNLoginInput2githubᚗcomᚋauthorizerdevᚋ return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) unmarshalNMagicLoginInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐMagicLoginInput(ctx context.Context, v interface{}) (model.MagicLoginInput, error) { - res, err := ec.unmarshalInputMagicLoginInput(ctx, v) +func (ec *executionContext) unmarshalNMagicLinkLoginInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐMagicLinkLoginInput(ctx context.Context, v interface{}) (model.MagicLinkLoginInput, error) { + res, err := ec.unmarshalInputMagicLinkLoginInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) } @@ -5049,6 +5509,12 @@ func (ec *executionContext) marshalNString2ᚕstringᚄ(ctx context.Context, sel ret[i] = ec.marshalNString2string(ctx, sel, v[i]) } + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + return ret } @@ -5057,6 +5523,11 @@ func (ec *executionContext) unmarshalNUpdateProfileInput2githubᚗcomᚋauthoriz return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) unmarshalNUpdateUserInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐUpdateUserInput(ctx context.Context, v interface{}) (model.UpdateUserInput, error) { + res, err := ec.unmarshalInputUpdateUserInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) marshalNUser2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v model.User) graphql.Marshaler { return ec._User(ctx, sel, &v) } @@ -5095,6 +5566,13 @@ func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋauthorizerdevᚋau } wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + return ret } @@ -5142,6 +5620,13 @@ func (ec *executionContext) marshalNVerificationRequest2ᚕᚖgithubᚗcomᚋaut } wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + return ret } @@ -5198,6 +5683,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq } wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + return ret } @@ -5271,6 +5763,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context } wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + return ret } @@ -5320,6 +5819,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + return ret } @@ -5361,6 +5867,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + return ret } @@ -5477,6 +5990,12 @@ func (ec *executionContext) marshalOString2ᚕstringᚄ(ctx context.Context, sel ret[i] = ec.marshalNString2string(ctx, sel, v[i]) } + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + return ret } @@ -5575,6 +6094,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq } wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + return ret } @@ -5615,6 +6141,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen } wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + return ret } @@ -5655,6 +6188,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg } wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + return ret } @@ -5702,6 +6242,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen } wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + return ret } diff --git a/server/graph/model/models_gen.go b/server/graph/model/models_gen.go index ea0cadd..513ef7d 100644 --- a/server/graph/model/models_gen.go +++ b/server/graph/model/models_gen.go @@ -2,20 +2,11 @@ package model -type AdminUpdateUserInput struct { - ID string `json:"id"` - Email *string `json:"email"` - FirstName *string `json:"firstName"` - LastName *string `json:"lastName"` - Image *string `json:"image"` - Roles []*string `json:"roles"` -} - type AuthResponse struct { - Message string `json:"message"` - AccessToken *string `json:"accessToken"` - AccessTokenExpiresAt *int64 `json:"accessTokenExpiresAt"` - User *User `json:"user"` + Message string `json:"message"` + AccessToken *string `json:"access_token"` + ExpiresAt *int64 `json:"expires_at"` + User *User `json:"user"` } type DeleteUserInput struct { @@ -37,20 +28,19 @@ type LoginInput struct { Roles []string `json:"roles"` } -type MagicLoginInput struct { +type MagicLinkLoginInput struct { Email string `json:"email"` Roles []string `json:"roles"` } type Meta struct { Version string `json:"version"` - IsGoogleLoginEnabled bool `json:"isGoogleLoginEnabled"` - IsFacebookLoginEnabled bool `json:"isFacebookLoginEnabled"` - IsTwitterLoginEnabled bool `json:"isTwitterLoginEnabled"` - IsGithubLoginEnabled bool `json:"isGithubLoginEnabled"` - IsEmailVerificationEnabled bool `json:"isEmailVerificationEnabled"` - IsBasicAuthenticationEnabled bool `json:"isBasicAuthenticationEnabled"` - IsMagicLoginEnabled bool `json:"isMagicLoginEnabled"` + IsGoogleLoginEnabled bool `json:"is_google_login_enabled"` + IsFacebookLoginEnabled bool `json:"is_facebook_login_enabled"` + IsGithubLoginEnabled bool `json:"is_github_login_enabled"` + IsEmailVerificationEnabled bool `json:"is_email_verification_enabled"` + IsBasicAuthenticationEnabled bool `json:"is_basic_authentication_enabled"` + IsMagicLinkLoginEnabled bool `json:"is_magic_link_login_enabled"` } type ResendVerifyEmailInput struct { @@ -60,7 +50,7 @@ type ResendVerifyEmailInput struct { type ResetPasswordInput struct { Token string `json:"token"` Password string `json:"password"` - ConfirmPassword string `json:"confirmPassword"` + ConfirmPassword string `json:"confirm_password"` } type Response struct { @@ -68,36 +58,67 @@ type Response struct { } type SignUpInput struct { - FirstName *string `json:"firstName"` - LastName *string `json:"lastName"` Email string `json:"email"` + GivenName *string `json:"given_name"` + FamilyName *string `json:"family_name"` + MiddleName *string `json:"middle_name"` + Nickname *string `json:"nickname"` + Gender *string `json:"gender"` + Birthdate *string `json:"birthdate"` + PhoneNumber *string `json:"phone_number"` + Picture *string `json:"picture"` Password string `json:"password"` - ConfirmPassword string `json:"confirmPassword"` - Image *string `json:"image"` + ConfirmPassword string `json:"confirm_password"` Roles []string `json:"roles"` } type UpdateProfileInput struct { - OldPassword *string `json:"oldPassword"` - NewPassword *string `json:"newPassword"` - ConfirmNewPassword *string `json:"confirmNewPassword"` - FirstName *string `json:"firstName"` - LastName *string `json:"lastName"` - Image *string `json:"image"` + OldPassword *string `json:"old_password"` + NewPassword *string `json:"new_password"` + ConfirmNewPassword *string `json:"confirm_new_password"` Email *string `json:"email"` + GivenName *string `json:"given_name"` + FamilyName *string `json:"family_name"` + MiddleName *string `json:"middle_name"` + Nickname *string `json:"nickname"` + Gender *string `json:"gender"` + Birthdate *string `json:"birthdate"` + PhoneNumber *string `json:"phone_number"` + Picture *string `json:"picture"` +} + +type UpdateUserInput struct { + ID string `json:"id"` + Email *string `json:"email"` + GivenName *string `json:"given_name"` + FamilyName *string `json:"family_name"` + MiddleName *string `json:"middle_name"` + Nickname *string `json:"nickname"` + Gender *string `json:"gender"` + Birthdate *string `json:"birthdate"` + PhoneNumber *string `json:"phone_number"` + Picture *string `json:"picture"` + Roles []*string `json:"roles"` } type User struct { - ID string `json:"id"` - Email string `json:"email"` - SignupMethod string `json:"signupMethod"` - FirstName *string `json:"firstName"` - LastName *string `json:"lastName"` - EmailVerifiedAt *int64 `json:"emailVerifiedAt"` - Image *string `json:"image"` - CreatedAt *int64 `json:"createdAt"` - UpdatedAt *int64 `json:"updatedAt"` - Roles []string `json:"roles"` + ID string `json:"id"` + Email string `json:"email"` + EmailVerified bool `json:"email_verified"` + SignupMethods string `json:"signup_methods"` + GivenName *string `json:"given_name"` + FamilyName *string `json:"family_name"` + MiddleName *string `json:"middle_name"` + Nickname *string `json:"nickname"` + PreferredUsername *string `json:"preferred_username"` + Gender *string `json:"gender"` + Birthdate *string `json:"birthdate"` + PhoneNumber *string `json:"phone_number"` + PhoneNumberVerified *bool `json:"phone_number_verified"` + Picture *string `json:"picture"` + Roles []string `json:"roles"` + CreatedAt *int64 `json:"created_at"` + UpdatedAt *int64 `json:"updated_at"` } type VerificationRequest struct { @@ -106,8 +127,8 @@ type VerificationRequest struct { Token *string `json:"token"` Email *string `json:"email"` Expires *int64 `json:"expires"` - CreatedAt *int64 `json:"createdAt"` - UpdatedAt *int64 `json:"updatedAt"` + CreatedAt *int64 `json:"created_at"` + UpdatedAt *int64 `json:"updated_at"` } type VerifyEmailInput struct { diff --git a/server/graph/schema.graphqls b/server/graph/schema.graphqls index aa94b55..937ecd5 100644 --- a/server/graph/schema.graphqls +++ b/server/graph/schema.graphqls @@ -7,26 +7,33 @@ scalar Any type Meta { version: String! - isGoogleLoginEnabled: Boolean! - isFacebookLoginEnabled: Boolean! - isTwitterLoginEnabled: Boolean! - isGithubLoginEnabled: Boolean! - isEmailVerificationEnabled: Boolean! - isBasicAuthenticationEnabled: Boolean! - isMagicLoginEnabled: Boolean! + is_google_login_enabled: Boolean! + is_facebook_login_enabled: Boolean! + is_github_login_enabled: Boolean! + is_email_verification_enabled: Boolean! + is_basic_authentication_enabled: Boolean! + is_magic_link_login_enabled: Boolean! } type User { id: ID! email: String! - signupMethod: String! - firstName: String - lastName: String - emailVerifiedAt: Int64 - image: String - createdAt: Int64 - updatedAt: Int64 + email_verified: Boolean! + signup_methods: String! + given_name: String + family_name: String + middle_name: String + nickname: String + # defaults to email + preferred_username: String + gender: String + birthdate: String + phone_number: String + phone_number_verified: Boolean + picture: String roles: [String!]! + created_at: Int64 + updated_at: Int64 } type VerificationRequest { @@ -35,8 +42,8 @@ type VerificationRequest { token: String email: String expires: Int64 - createdAt: Int64 - updatedAt: Int64 + created_at: Int64 + updated_at: Int64 } type Error { @@ -46,8 +53,8 @@ type Error { type AuthResponse { message: String! - accessToken: String - accessTokenExpiresAt: Int64 + access_token: String + expires_at: Int64 user: User } @@ -56,12 +63,17 @@ type Response { } input SignUpInput { - firstName: String - lastName: String email: String! + given_name: String + family_name: String + middle_name: String + nickname: String + gender: String + birthdate: String + phone_number: String + picture: String password: String! - confirmPassword: String! - image: String + confirm_password: String! roles: [String!] } @@ -80,22 +92,31 @@ input ResendVerifyEmailInput { } input UpdateProfileInput { - oldPassword: String - newPassword: String - confirmNewPassword: String - firstName: String - lastName: String - image: String + old_password: String + new_password: String + confirm_new_password: String email: String - # roles: [String] + given_name: String + family_name: String + middle_name: String + nickname: String + gender: String + birthdate: String + phone_number: String + picture: String } -input AdminUpdateUserInput { +input UpdateUserInput { id: ID! email: String - firstName: String - lastName: String - image: String + given_name: String + family_name: String + middle_name: String + nickname: String + gender: String + birthdate: String + phone_number: String + picture: String roles: [String] } @@ -106,14 +127,14 @@ input ForgotPasswordInput { input ResetPasswordInput { token: String! password: String! - confirmPassword: String! + confirm_password: String! } input DeleteUserInput { email: String! } -input MagicLoginInput { +input MagicLinkLoginInput { email: String! roles: [String!] } @@ -121,21 +142,23 @@ input MagicLoginInput { type Mutation { signup(params: SignUpInput!): AuthResponse! login(params: LoginInput!): AuthResponse! - magicLogin(params: MagicLoginInput!): Response! + magic_link_login(params: MagicLinkLoginInput!): Response! logout: Response! - updateProfile(params: UpdateProfileInput!): Response! - adminUpdateUser(params: AdminUpdateUserInput!): User! - verifyEmail(params: VerifyEmailInput!): AuthResponse! - resendVerifyEmail(params: ResendVerifyEmailInput!): Response! - forgotPassword(params: ForgotPasswordInput!): Response! - resetPassword(params: ResetPasswordInput!): Response! - deleteUser(params: DeleteUserInput!): Response! + update_profile(params: UpdateProfileInput!): Response! + verify_email(params: VerifyEmailInput!): AuthResponse! + resend_verify_email(params: ResendVerifyEmailInput!): Response! + forgot_password(params: ForgotPasswordInput!): Response! + reset_password(params: ResetPasswordInput!): Response! + # admin only apis + _delete_user(params: DeleteUserInput!): Response! + _update_user(params: UpdateUserInput!): User! } type Query { meta: Meta! - users: [User!]! token(roles: [String!]): AuthResponse profile: User! - verificationRequests: [VerificationRequest!]! + # admin only apis + _users: [User!]! + _verification_requests: [VerificationRequest!]! } diff --git a/server/graph/schema.resolvers.go b/server/graph/schema.resolvers.go index ea1a1fc..21785d2 100644 --- a/server/graph/schema.resolvers.go +++ b/server/graph/schema.resolvers.go @@ -19,8 +19,8 @@ func (r *mutationResolver) Login(ctx context.Context, params model.LoginInput) ( return resolvers.Login(ctx, params) } -func (r *mutationResolver) MagicLogin(ctx context.Context, params model.MagicLoginInput) (*model.Response, error) { - return resolvers.MagicLogin(ctx, params) +func (r *mutationResolver) MagicLinkLogin(ctx context.Context, params model.MagicLinkLoginInput) (*model.Response, error) { + return resolvers.MagicLinkLogin(ctx, params) } func (r *mutationResolver) Logout(ctx context.Context) (*model.Response, error) { @@ -31,10 +31,6 @@ func (r *mutationResolver) UpdateProfile(ctx context.Context, params model.Updat return resolvers.UpdateProfile(ctx, params) } -func (r *mutationResolver) AdminUpdateUser(ctx context.Context, params model.AdminUpdateUserInput) (*model.User, error) { - return resolvers.AdminUpdateUser(ctx, params) -} - func (r *mutationResolver) VerifyEmail(ctx context.Context, params model.VerifyEmailInput) (*model.AuthResponse, error) { return resolvers.VerifyEmail(ctx, params) } @@ -55,12 +51,12 @@ func (r *mutationResolver) DeleteUser(ctx context.Context, params model.DeleteUs return resolvers.DeleteUser(ctx, params) } -func (r *queryResolver) Meta(ctx context.Context) (*model.Meta, error) { - return resolvers.Meta(ctx) +func (r *mutationResolver) UpdateUser(ctx context.Context, params model.UpdateUserInput) (*model.User, error) { + return resolvers.UpdateUser(ctx, params) } -func (r *queryResolver) Users(ctx context.Context) ([]*model.User, error) { - return resolvers.Users(ctx) +func (r *queryResolver) Meta(ctx context.Context) (*model.Meta, error) { + return resolvers.Meta(ctx) } func (r *queryResolver) Token(ctx context.Context, roles []string) (*model.AuthResponse, error) { @@ -71,6 +67,10 @@ func (r *queryResolver) Profile(ctx context.Context) (*model.User, error) { return resolvers.Profile(ctx) } +func (r *queryResolver) Users(ctx context.Context) ([]*model.User, error) { + return resolvers.Users(ctx) +} + func (r *queryResolver) VerificationRequests(ctx context.Context) ([]*model.VerificationRequest, error) { return resolvers.VerificationRequests(ctx) } @@ -81,5 +81,7 @@ func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResol // Query returns generated.QueryResolver implementation. func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } -type mutationResolver struct{ *Resolver } -type queryResolver struct{ *Resolver } +type ( + mutationResolver struct{ *Resolver } + queryResolver struct{ *Resolver } +) diff --git a/server/handlers/oauthCallback.go b/server/handlers/oauth_callback.go similarity index 87% rename from server/handlers/oauthCallback.go rename to server/handlers/oauth_callback.go index 7632d30..6612db4 100644 --- a/server/handlers/oauthCallback.go +++ b/server/handlers/oauth_callback.go @@ -43,26 +43,10 @@ func processGoogleUserInfo(code string) (db.User, error) { return user, fmt.Errorf("unable to verify id_token: %s", err.Error()) } - // Extract custom claims - var claims struct { - Email string `json:"email"` - Picture string `json:"picture"` - GivenName string `json:"given_name"` - FamilyName string `json:"family_name"` - Verified bool `json:"email_verified"` - } - if err := idToken.Claims(&claims); err != nil { + if err := idToken.Claims(&user); err != nil { return user, fmt.Errorf("unable to extract claims") } - user = db.User{ - FirstName: claims.GivenName, - LastName: claims.FamilyName, - Image: claims.Picture, - Email: claims.Email, - EmailVerifiedAt: time.Now().Unix(), - } - return user, nil } @@ -104,12 +88,12 @@ func processGithubUserInfo(code string) (db.User, error) { if len(name) > 1 && strings.TrimSpace(name[1]) != "" { lastName = name[0] } + user = db.User{ - FirstName: firstName, - LastName: lastName, - Image: userRawData["avatar_url"], - Email: userRawData["email"], - EmailVerifiedAt: time.Now().Unix(), + GivenName: firstName, + FamilyName: lastName, + Picture: userRawData["avatar_url"], + Email: userRawData["email"], } return user, nil @@ -147,11 +131,10 @@ func processFacebookUserInfo(code string) (db.User, error) { picObject := userRawData["picture"].(map[string]interface{})["data"] picDataObject := picObject.(map[string]interface{}) user = db.User{ - FirstName: fmt.Sprintf("%v", userRawData["first_name"]), - LastName: fmt.Sprintf("%v", userRawData["last_name"]), - Image: fmt.Sprintf("%v", picDataObject["url"]), - Email: email, - EmailVerifiedAt: time.Now().Unix(), + GivenName: fmt.Sprintf("%v", userRawData["first_name"]), + FamilyName: fmt.Sprintf("%v", userRawData["last_name"]), + Picture: fmt.Sprintf("%v", picDataObject["url"]), + Email: email, } return user, nil @@ -202,7 +185,7 @@ func OAuthCallbackHandler() gin.HandlerFunc { if err != nil { // user not registered, register user and generate session token - user.SignupMethod = provider + user.SignupMethods = provider // make sure inputRoles don't include protected roles hasProtectedRole := false for _, ir := range inputRoles { @@ -217,16 +200,17 @@ func OAuthCallbackHandler() gin.HandlerFunc { } user.Roles = strings.Join(inputRoles, ",") + user.EmailVerifiedAt = time.Now().Unix() user, _ = db.Mgr.AddUser(user) } else { // user exists in db, check if method was google // if not append google to existing signup method and save it - signupMethod := existingUser.SignupMethod + signupMethod := existingUser.SignupMethods if !strings.Contains(signupMethod, provider) { signupMethod = signupMethod + "," + provider } - user.SignupMethod = signupMethod + user.SignupMethods = signupMethod user.Password = existingUser.Password // There multiple scenarios with roles here in social login @@ -262,7 +246,7 @@ func OAuthCallbackHandler() gin.HandlerFunc { user.Roles = existingUser.Roles } user.Key = existingUser.Key - user.ObjectID = existingUser.ObjectID + // user.ObjectID = existingUser.ObjectID user.ID = existingUser.ID user, err = db.Mgr.UpdateUser(user) } diff --git a/server/handlers/oauthLogin.go b/server/handlers/oauth_login.go similarity index 100% rename from server/handlers/oauthLogin.go rename to server/handlers/oauth_login.go diff --git a/server/handlers/verifyEmail.go b/server/handlers/verify_email.go similarity index 100% rename from server/handlers/verifyEmail.go rename to server/handlers/verify_email.go diff --git a/server/integration_test/cors_test.go b/server/integration_test/cors_test.go index 226c1be..4ea2a9a 100644 --- a/server/integration_test/cors_test.go +++ b/server/integration_test/cors_test.go @@ -14,6 +14,8 @@ import ( ) func TestCors(t *testing.T) { + constants.DATABASE_TYPE = "sqlite" + constants.DATABASE_URL = "data.db" constants.ENV_PATH = "../../.env.local" env.InitEnv() r := gin.Default() diff --git a/server/main.go b/server/main.go index 8fb5374..e015fc5 100644 --- a/server/main.go +++ b/server/main.go @@ -1,6 +1,7 @@ package main import ( + "github.com/authorizerdev/authorizer/server/constants" "github.com/authorizerdev/authorizer/server/db" "github.com/authorizerdev/authorizer/server/env" "github.com/authorizerdev/authorizer/server/handlers" @@ -40,5 +41,5 @@ func main() { app.GET("/reset-password", handlers.AppHandler()) } - r.Run() + r.Run(":" + constants.PORT) } diff --git a/server/middlewares/context.go b/server/middlewares/context.go index 390a078..32e824b 100644 --- a/server/middlewares/context.go +++ b/server/middlewares/context.go @@ -14,7 +14,7 @@ func GinContextToContextMiddleware() gin.HandlerFunc { if constants.AUTHORIZER_URL == "" { url := location.Get(c) constants.AUTHORIZER_URL = url.Scheme + "://" + c.Request.Host - log.Println("=> authorizer url:", constants.AUTHORIZER_URL) + log.Println("authorizer url:", constants.AUTHORIZER_URL) } ctx := context.WithValue(c.Request.Context(), "GinContextKey", c) c.Request = c.Request.WithContext(ctx) diff --git a/server/resolvers/deleteUser.go b/server/resolvers/delete_user.go similarity index 100% rename from server/resolvers/deleteUser.go rename to server/resolvers/delete_user.go diff --git a/server/resolvers/forgotPassword.go b/server/resolvers/forgot_password.go similarity index 100% rename from server/resolvers/forgotPassword.go rename to server/resolvers/forgot_password.go diff --git a/server/resolvers/login.go b/server/resolvers/login.go index 8d8912c..34cf5ba 100644 --- a/server/resolvers/login.go +++ b/server/resolvers/login.go @@ -32,7 +32,7 @@ func Login(ctx context.Context, params model.LoginInput) (*model.AuthResponse, e return res, fmt.Errorf(`user with this email not found`) } - if !strings.Contains(user.SignupMethod, enum.BasicAuth.String()) { + if !strings.Contains(user.SignupMethods, enum.BasicAuth.String()) { return res, fmt.Errorf(`user has not signed up email & password`) } @@ -55,12 +55,11 @@ func Login(ctx context.Context, params model.LoginInput) (*model.AuthResponse, e roles = params.Roles } - userIdStr := fmt.Sprintf("%v", user.ID) refreshToken, _, _ := utils.CreateAuthToken(user, enum.RefreshToken, roles) accessToken, expiresAt, _ := utils.CreateAuthToken(user, enum.AccessToken, roles) - session.SetToken(userIdStr, accessToken, refreshToken) + session.SetToken(user.ID, accessToken, refreshToken) go func() { sessionData := db.Session{ UserID: user.ID, @@ -72,21 +71,10 @@ func Login(ctx context.Context, params model.LoginInput) (*model.AuthResponse, e }() res = &model.AuthResponse{ - Message: `Logged in successfully`, - AccessToken: &accessToken, - AccessTokenExpiresAt: &expiresAt, - User: &model.User{ - ID: userIdStr, - Email: user.Email, - Image: &user.Image, - FirstName: &user.FirstName, - LastName: &user.LastName, - SignupMethod: user.SignupMethod, - EmailVerifiedAt: &user.EmailVerifiedAt, - Roles: strings.Split(user.Roles, ","), - CreatedAt: &user.CreatedAt, - UpdatedAt: &user.UpdatedAt, - }, + Message: `Logged in successfully`, + AccessToken: &accessToken, + ExpiresAt: &expiresAt, + User: utils.GetResUser(user), } utils.SetCookie(gc, accessToken) diff --git a/server/resolvers/magicLogin.go b/server/resolvers/magic_link_login.go similarity index 92% rename from server/resolvers/magicLogin.go rename to server/resolvers/magic_link_login.go index 8d521d9..57e2690 100644 --- a/server/resolvers/magicLogin.go +++ b/server/resolvers/magic_link_login.go @@ -14,10 +14,10 @@ import ( "github.com/authorizerdev/authorizer/server/utils" ) -func MagicLogin(ctx context.Context, params model.MagicLoginInput) (*model.Response, error) { +func MagicLinkLogin(ctx context.Context, params model.MagicLinkLoginInput) (*model.Response, error) { var res *model.Response - if constants.DISABLE_MAGIC_LOGIN { + if constants.DISABLE_MAGIC_LINK_LOGIN { return res, fmt.Errorf(`magic link login is disabled for this instance`) } @@ -37,7 +37,7 @@ func MagicLogin(ctx context.Context, params model.MagicLoginInput) (*model.Respo existingUser, err := db.Mgr.GetUserByEmail(params.Email) if err != nil { - user.SignupMethod = enum.MagicLink.String() + user.SignupMethods = enum.MagicLink.String() // define roles for new user if len(params.Roles) > 0 { // check if roles exists @@ -86,12 +86,12 @@ func MagicLogin(ctx context.Context, params model.MagicLoginInput) (*model.Respo user.Roles = existingUser.Roles } - signupMethod := existingUser.SignupMethod + signupMethod := existingUser.SignupMethods if !strings.Contains(signupMethod, enum.MagicLink.String()) { signupMethod = signupMethod + "," + enum.MagicLink.String() } - user.SignupMethod = signupMethod + user.SignupMethods = signupMethod user, _ = db.Mgr.UpdateUser(user) if err != nil { log.Println("error updating user:", err) diff --git a/server/resolvers/profile.go b/server/resolvers/profile.go index f11b1fb..f65460d 100644 --- a/server/resolvers/profile.go +++ b/server/resolvers/profile.go @@ -3,7 +3,6 @@ package resolvers import ( "context" "fmt" - "strings" "github.com/authorizerdev/authorizer/server/db" "github.com/authorizerdev/authorizer/server/graph/model" @@ -41,20 +40,7 @@ func Profile(ctx context.Context) (*model.User, error) { return res, err } - userIdStr := fmt.Sprintf("%v", user.ID) - - res = &model.User{ - ID: userIdStr, - Email: user.Email, - Image: &user.Image, - FirstName: &user.FirstName, - LastName: &user.LastName, - SignupMethod: user.SignupMethod, - EmailVerifiedAt: &user.EmailVerifiedAt, - Roles: strings.Split(user.Roles, ","), - CreatedAt: &user.CreatedAt, - UpdatedAt: &user.UpdatedAt, - } + res = utils.GetResUser(user) return res, nil } diff --git a/server/resolvers/resendVerifyEmail.go b/server/resolvers/resend_verify_email.go similarity index 100% rename from server/resolvers/resendVerifyEmail.go rename to server/resolvers/resend_verify_email.go diff --git a/server/resolvers/resetPassword.go b/server/resolvers/reset_password.go similarity index 95% rename from server/resolvers/resetPassword.go rename to server/resolvers/reset_password.go index 0cc43de..2b5a132 100644 --- a/server/resolvers/resetPassword.go +++ b/server/resolvers/reset_password.go @@ -41,11 +41,11 @@ func ResetPassword(ctx context.Context, params model.ResetPasswordInput) (*model password, _ := utils.HashPassword(params.Password) user.Password = password - signupMethod := user.SignupMethod + signupMethod := user.SignupMethods if !strings.Contains(signupMethod, enum.BasicAuth.String()) { signupMethod = signupMethod + "," + enum.BasicAuth.String() } - user.SignupMethod = signupMethod + user.SignupMethods = signupMethod // delete from verification table db.Mgr.DeleteVerificationRequest(verificationRequest) diff --git a/server/resolvers/signup.go b/server/resolvers/signup.go index 23ac14f..6c72b6e 100644 --- a/server/resolvers/signup.go +++ b/server/resolvers/signup.go @@ -70,15 +70,39 @@ func Signup(ctx context.Context, params model.SignUpInput) (*model.AuthResponse, password, _ := utils.HashPassword(params.Password) user.Password = password - if params.FirstName != nil { - user.FirstName = *params.FirstName + if params.GivenName != nil { + user.GivenName = *params.GivenName } - if params.LastName != nil { - user.LastName = *params.LastName + if params.FamilyName != nil { + user.FamilyName = *params.FamilyName } - user.SignupMethod = enum.BasicAuth.String() + if params.MiddleName != nil { + user.MiddleName = *params.MiddleName + } + + if params.Nickname != nil { + user.Nickname = *params.Nickname + } + + if params.Gender != nil { + user.Gender = *params.Gender + } + + if params.Birthdate != nil { + user.Birthdate = *params.Birthdate + } + + if params.PhoneNumber != nil { + user.PhoneNumber = *params.PhoneNumber + } + + if params.Picture != nil { + user.Picture = *params.Picture + } + + user.SignupMethods = enum.BasicAuth.String() if constants.DISABLE_EMAIL_VERIFICATION { user.EmailVerifiedAt = time.Now().Unix() } @@ -88,18 +112,7 @@ func Signup(ctx context.Context, params model.SignUpInput) (*model.AuthResponse, } userIdStr := fmt.Sprintf("%v", user.ID) roles := strings.Split(user.Roles, ",") - userToReturn := &model.User{ - ID: userIdStr, - Email: user.Email, - Image: &user.Image, - FirstName: &user.FirstName, - LastName: &user.LastName, - SignupMethod: user.SignupMethod, - EmailVerifiedAt: &user.EmailVerifiedAt, - Roles: strings.Split(user.Roles, ","), - CreatedAt: &user.CreatedAt, - UpdatedAt: &user.UpdatedAt, - } + userToReturn := utils.GetResUser(user) if !constants.DISABLE_EMAIL_VERIFICATION { // insert verification request @@ -141,10 +154,10 @@ func Signup(ctx context.Context, params model.SignUpInput) (*model.AuthResponse, db.Mgr.AddSession(sessionData) }() res = &model.AuthResponse{ - Message: `Signed up successfully.`, - AccessToken: &accessToken, - AccessTokenExpiresAt: &expiresAt, - User: userToReturn, + Message: `Signed up successfully.`, + AccessToken: &accessToken, + ExpiresAt: &expiresAt, + User: userToReturn, } utils.SetCookie(gc, accessToken) diff --git a/server/resolvers/token.go b/server/resolvers/token.go index 39b9367..12b4d39 100644 --- a/server/resolvers/token.go +++ b/server/resolvers/token.go @@ -3,7 +3,6 @@ package resolvers import ( "context" "fmt" - "strings" "time" "github.com/authorizerdev/authorizer/server/constants" @@ -80,21 +79,10 @@ func Token(ctx context.Context, roles []string) (*model.AuthResponse, error) { utils.SetCookie(gc, token) res = &model.AuthResponse{ - Message: `Token verified`, - AccessToken: &token, - AccessTokenExpiresAt: &expiresAt, - User: &model.User{ - ID: userIdStr, - Email: user.Email, - Image: &user.Image, - FirstName: &user.FirstName, - LastName: &user.LastName, - Roles: strings.Split(user.Roles, ","), - CreatedAt: &user.CreatedAt, - UpdatedAt: &user.UpdatedAt, - SignupMethod: user.SignupMethod, - EmailVerifiedAt: &user.EmailVerifiedAt, - }, + Message: `Token verified`, + AccessToken: &token, + ExpiresAt: &expiresAt, + User: utils.GetResUser(user), } return res, nil } diff --git a/server/resolvers/updateProfile.go b/server/resolvers/update_profile.go similarity index 74% rename from server/resolvers/updateProfile.go rename to server/resolvers/update_profile.go index 2335d16..d626173 100644 --- a/server/resolvers/updateProfile.go +++ b/server/resolvers/update_profile.go @@ -40,7 +40,7 @@ func UpdateProfile(ctx context.Context, params model.UpdateProfileInput) (*model } // validate if all params are not empty - if params.FirstName == nil && params.LastName == nil && params.Image == nil && params.OldPassword == nil && params.Email == nil { + if params.GivenName == nil && params.FamilyName == nil && params.Picture == nil && params.MiddleName == nil && params.Nickname == nil && params.OldPassword == nil && params.Email == nil && params.Birthdate == nil && params.Gender == nil && params.PhoneNumber == nil { return res, fmt.Errorf("please enter atleast one param to update") } @@ -50,16 +50,36 @@ func UpdateProfile(ctx context.Context, params model.UpdateProfileInput) (*model return res, err } - if params.FirstName != nil && user.FirstName != *params.FirstName { - user.FirstName = *params.FirstName + if params.GivenName != nil && user.GivenName != *params.GivenName { + user.GivenName = *params.GivenName } - if params.LastName != nil && user.LastName != *params.LastName { - user.LastName = *params.LastName + if params.FamilyName != nil && user.FamilyName != *params.FamilyName { + user.FamilyName = *params.FamilyName } - if params.Image != nil && user.Image != *params.Image { - user.Image = *params.Image + if params.MiddleName != nil && user.MiddleName != *params.MiddleName { + user.MiddleName = *params.MiddleName + } + + if params.Nickname != nil && user.Nickname != *params.Nickname { + user.Nickname = *params.Nickname + } + + if params.Birthdate != nil && user.Birthdate != *params.Birthdate { + user.Birthdate = *params.Birthdate + } + + if params.Gender != nil && user.Gender != *params.Gender { + user.Gender = *params.Gender + } + + if params.PhoneNumber != nil && user.PhoneNumber != *params.PhoneNumber { + user.PhoneNumber = *params.PhoneNumber + } + + if params.Picture != nil && user.Picture != *params.Picture { + user.Picture = *params.Picture } if params.OldPassword != nil { diff --git a/server/resolvers/adminUpdateUser.go b/server/resolvers/update_user.go similarity index 65% rename from server/resolvers/adminUpdateUser.go rename to server/resolvers/update_user.go index 602b7da..e596757 100644 --- a/server/resolvers/adminUpdateUser.go +++ b/server/resolvers/update_user.go @@ -15,7 +15,7 @@ import ( "github.com/authorizerdev/authorizer/server/utils" ) -func AdminUpdateUser(ctx context.Context, params model.AdminUpdateUserInput) (*model.User, error) { +func UpdateUser(ctx context.Context, params model.UpdateUserInput) (*model.User, error) { gc, err := utils.GinContextFromContext(ctx) var res *model.User if err != nil { @@ -26,7 +26,7 @@ func AdminUpdateUser(ctx context.Context, params model.AdminUpdateUserInput) (*m return res, fmt.Errorf("unauthorized") } - if params.FirstName == nil && params.LastName == nil && params.Image == nil && params.Email == nil && params.Roles == nil { + if params.GivenName == nil && params.FamilyName == nil && params.Picture == nil && params.MiddleName == nil && params.Nickname == nil && params.Email == nil && params.Birthdate == nil && params.Gender == nil && params.PhoneNumber == nil && params.Roles == nil { return res, fmt.Errorf("please enter atleast one param to update") } @@ -35,16 +35,36 @@ func AdminUpdateUser(ctx context.Context, params model.AdminUpdateUserInput) (*m return res, fmt.Errorf(`User not found`) } - if params.FirstName != nil && user.FirstName != *params.FirstName { - user.FirstName = *params.FirstName + if params.GivenName != nil && user.GivenName != *params.GivenName { + user.GivenName = *params.GivenName } - if params.LastName != nil && user.LastName != *params.LastName { - user.LastName = *params.LastName + if params.FamilyName != nil && user.FamilyName != *params.FamilyName { + user.FamilyName = *params.FamilyName } - if params.Image != nil && user.Image != *params.Image { - user.Image = *params.Image + if params.MiddleName != nil && user.MiddleName != *params.MiddleName { + user.MiddleName = *params.MiddleName + } + + if params.Nickname != nil && user.Nickname != *params.Nickname { + user.Nickname = *params.Nickname + } + + if params.Birthdate != nil && user.Birthdate != *params.Birthdate { + user.Birthdate = *params.Birthdate + } + + if params.Gender != nil && user.Gender != *params.Gender { + user.Gender = *params.Gender + } + + if params.PhoneNumber != nil && user.PhoneNumber != *params.PhoneNumber { + user.PhoneNumber = *params.PhoneNumber + } + + if params.Picture != nil && user.Picture != *params.Picture { + user.Picture = *params.Picture } if params.Email != nil && user.Email != *params.Email { @@ -115,14 +135,14 @@ func AdminUpdateUser(ctx context.Context, params model.AdminUpdateUserInput) (*m } res = &model.User{ - ID: params.ID, - Email: user.Email, - Image: &user.Image, - FirstName: &user.FirstName, - LastName: &user.LastName, - Roles: strings.Split(user.Roles, ","), - CreatedAt: &user.CreatedAt, - UpdatedAt: &user.UpdatedAt, + ID: params.ID, + Email: user.Email, + Picture: &user.Picture, + GivenName: &user.GivenName, + FamilyName: &user.FamilyName, + Roles: strings.Split(user.Roles, ","), + CreatedAt: &user.CreatedAt, + UpdatedAt: &user.UpdatedAt, } return res, nil } diff --git a/server/resolvers/users.go b/server/resolvers/users.go index 279f9e3..07dbee8 100644 --- a/server/resolvers/users.go +++ b/server/resolvers/users.go @@ -3,7 +3,6 @@ package resolvers import ( "context" "fmt" - "strings" "github.com/authorizerdev/authorizer/server/db" "github.com/authorizerdev/authorizer/server/graph/model" @@ -27,17 +26,7 @@ func Users(ctx context.Context) ([]*model.User, error) { } for i := 0; i < len(users); i++ { - res = append(res, &model.User{ - ID: fmt.Sprintf("%v", users[i].ID), - Email: users[i].Email, - SignupMethod: users[i].SignupMethod, - FirstName: &users[i].FirstName, - LastName: &users[i].LastName, - EmailVerifiedAt: &users[i].EmailVerifiedAt, - Roles: strings.Split(users[i].Roles, ","), - CreatedAt: &users[i].CreatedAt, - UpdatedAt: &users[i].UpdatedAt, - }) + res = append(res, utils.GetResUser(users[i])) } return res, nil diff --git a/server/resolvers/verificationRequests.go b/server/resolvers/verification_requests.go similarity index 100% rename from server/resolvers/verificationRequests.go rename to server/resolvers/verification_requests.go diff --git a/server/resolvers/verifyEmail.go b/server/resolvers/verify_email.go similarity index 76% rename from server/resolvers/verifyEmail.go rename to server/resolvers/verify_email.go index b1febe0..0a15e38 100644 --- a/server/resolvers/verifyEmail.go +++ b/server/resolvers/verify_email.go @@ -60,21 +60,10 @@ func VerifyEmail(ctx context.Context, params model.VerifyEmailInput) (*model.Aut }() res = &model.AuthResponse{ - Message: `Email verified successfully.`, - AccessToken: &accessToken, - AccessTokenExpiresAt: &expiresAt, - User: &model.User{ - ID: userIdStr, - Email: user.Email, - Image: &user.Image, - FirstName: &user.FirstName, - LastName: &user.LastName, - SignupMethod: user.SignupMethod, - EmailVerifiedAt: &user.EmailVerifiedAt, - Roles: strings.Split(user.Roles, ","), - CreatedAt: &user.CreatedAt, - UpdatedAt: &user.UpdatedAt, - }, + Message: `Email verified successfully.`, + AccessToken: &accessToken, + ExpiresAt: &expiresAt, + User: utils.GetResUser(user), } utils.SetCookie(gc, accessToken) diff --git a/server/session/inMemoryStore.go b/server/session/in_memory_session.go similarity index 100% rename from server/session/inMemoryStore.go rename to server/session/in_memory_session.go diff --git a/server/session/redisStore.go b/server/session/redis_store.go similarity index 100% rename from server/session/redisStore.go rename to server/session/redis_store.go diff --git a/server/utils/authToken.go b/server/utils/auth_token.go similarity index 87% rename from server/utils/authToken.go rename to server/utils/auth_token.go index 5a9baba..5c8ce75 100644 --- a/server/utils/authToken.go +++ b/server/utils/auth_token.go @@ -26,34 +26,31 @@ func CreateAuthToken(user db.User, tokenType enum.TokenType, roles []string) (st expiresAt := time.Now().Add(expiryBound).Unix() + resUser := GetResUser(user) + userBytes, _ := json.Marshal(&resUser) + var userMap map[string]interface{} + json.Unmarshal(userBytes, &userMap) + customClaims := jwt.MapClaims{ "exp": expiresAt, "iat": time.Now().Unix(), "token_type": tokenType.String(), - "email": user.Email, - "id": user.ID, "allowed_roles": strings.Split(user.Roles, ","), constants.JWT_ROLE_CLAIM: roles, } - // check for the extra access token script + for k, v := range userMap { + if k != "roles" { + customClaims[k] = v + } + } + // check for the extra access token script accessTokenScript := os.Getenv("CUSTOM_ACCESS_TOKEN_SCRIPT") if accessTokenScript != "" { - userInfo := map[string]interface{}{ - "id": user.ID, - "email": user.Email, - "firstName": user.FirstName, - "lastName": user.LastName, - "image": user.Image, - "roles": strings.Split(user.Roles, ","), - "signUpMethods": strings.Split(user.SignupMethod, ","), - } - vm := otto.New() - userBytes, _ := json.Marshal(userInfo) - claimBytes, _ := json.Marshal(customClaims) + claimBytes, _ := json.Marshal(customClaims) vm.Run(fmt.Sprintf(` var user = %s; var tokenPayload = %s; diff --git a/server/utils/get_res_user.go b/server/utils/get_res_user.go new file mode 100644 index 0000000..e63e739 --- /dev/null +++ b/server/utils/get_res_user.go @@ -0,0 +1,32 @@ +package utils + +import ( + "strings" + + "github.com/authorizerdev/authorizer/server/db" + "github.com/authorizerdev/authorizer/server/graph/model" +) + +func GetResUser(user db.User) *model.User { + isEmailVerified := user.EmailVerifiedAt > 0 + isPhoneVerified := user.PhoneNumberVerifiedAt > 0 + return &model.User{ + ID: user.ID, + Email: user.Email, + EmailVerified: isEmailVerified, + SignupMethods: user.SignupMethods, + GivenName: &user.GivenName, + FamilyName: &user.FamilyName, + MiddleName: &user.MiddleName, + Nickname: &user.Nickname, + PreferredUsername: &user.Email, + Gender: &user.Gender, + Birthdate: &user.Birthdate, + PhoneNumber: &user.PhoneNumber, + PhoneNumberVerified: &isPhoneVerified, + Picture: &user.Picture, + Roles: strings.Split(user.Roles, ","), + CreatedAt: &user.CreatedAt, + UpdatedAt: &user.UpdatedAt, + } +} diff --git a/server/utils/ginContext.go b/server/utils/gin_context.go similarity index 100% rename from server/utils/ginContext.go rename to server/utils/gin_context.go diff --git a/server/utils/hashPassword.go b/server/utils/hash_password.go similarity index 100% rename from server/utils/hashPassword.go rename to server/utils/hash_password.go diff --git a/server/utils/initServer.go b/server/utils/init_server.go similarity index 100% rename from server/utils/initServer.go rename to server/utils/init_server.go diff --git a/server/utils/meta.go b/server/utils/meta.go index 9aa06c1..e7c2e6e 100644 --- a/server/utils/meta.go +++ b/server/utils/meta.go @@ -13,9 +13,8 @@ func GetMetaInfo() model.Meta { IsGoogleLoginEnabled: constants.GOOGLE_CLIENT_ID != "" && constants.GOOGLE_CLIENT_SECRET != "", IsGithubLoginEnabled: constants.GITHUB_CLIENT_ID != "" && constants.GOOGLE_CLIENT_SECRET != "", IsFacebookLoginEnabled: constants.FACEBOOK_CLIENT_ID != "" && constants.FACEBOOK_CLIENT_SECRET != "", - IsTwitterLoginEnabled: constants.TWITTER_CLIENT_ID != "" && constants.TWITTER_CLIENT_SECRET != "", IsBasicAuthenticationEnabled: !constants.DISABLE_BASIC_AUTHENTICATION, IsEmailVerificationEnabled: !constants.DISABLE_EMAIL_VERIFICATION, - IsMagicLoginEnabled: !constants.DISABLE_MAGIC_LOGIN, + IsMagicLinkLoginEnabled: !constants.DISABLE_MAGIC_LINK_LOGIN, } } diff --git a/server/utils/requestInfo.go b/server/utils/request_info.go similarity index 100% rename from server/utils/requestInfo.go rename to server/utils/request_info.go diff --git a/server/utils/verificationToken.go b/server/utils/verification_token.go similarity index 100% rename from server/utils/verificationToken.go rename to server/utils/verification_token.go