fix: env init (#33)

This commit is contained in:
Lakhan Samani 2021-07-28 11:53:37 +05:30 committed by GitHub
parent 0fd4f18dc1
commit ea320c2401
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 190 additions and 188 deletions

View File

@ -0,0 +1,28 @@
package constants
var (
ROOT_SECRET = ""
ENV = ""
DATABASE_TYPE = ""
DATABASE_URL = ""
SMTP_HOST = ""
SMTP_PORT = ""
SENDER_EMAIL = ""
SENDER_PASSWORD = ""
JWT_TYPE = ""
JWT_SECRET = ""
FRONTEND_URL = ""
SERVER_URL = ""
PORT = "8080"
REDIS_URL = ""
IS_PROD = false
COOKIE_NAME = ""
GOOGLE_CLIENT_ID = ""
GOOGLE_CLIENT_SECRET = ""
GITHUB_CLIENT_ID = ""
GITHUB_CLIENT_SECRET = ""
// FACEBOOK_CLIENT_ID = ""
// FACEBOOK_CLIENT_SECRET = ""
FORGOT_PASSWORD_URI = ""
VERIFY_EMAIL_URI = ""
)

View File

@ -1,116 +0,0 @@
package constants
import (
"flag"
"log"
"os"
"strings"
"github.com/authorizerdev/authorizer/server/enum"
"github.com/joho/godotenv"
)
var (
ROOT_SECRET = ""
ENV = ""
DB_TYPE = ""
DB_URL = ""
SMTP_HOST = ""
SMTP_PORT = ""
SENDER_EMAIL = ""
SENDER_PASSWORD = ""
JWT_TYPE = ""
JWT_SECRET = ""
FRONTEND_URL = ""
SERVER_URL = ""
PORT = "8080"
REDIS_URL = ""
IS_PROD = false
COOKIE_NAME = ""
GOOGLE_CLIENT_ID = ""
GOOGLE_CLIENT_SECRET = ""
GITHUB_CLIENT_ID = ""
GITHUB_CLIENT_SECRET = ""
// FACEBOOK_CLIENT_ID = ""
// FACEBOOK_CLIENT_SECRET = ""
FORGOT_PASSWORD_URI = ""
VERIFY_EMAIL_URI = ""
)
func ParseArgs() {
dbURL := flag.String("db_url", "", "Database connection string")
dbType := flag.String("db_type", "", "Database type, possible values are postgres,mysql,sqlit")
flag.Parse()
if *dbURL != "" {
DB_URL = *dbURL
}
if *dbType != "" {
DB_TYPE = *dbType
}
}
func init() {
err := godotenv.Load()
if err != nil {
log.Println("Error loading .env file")
}
ROOT_SECRET = os.Getenv("ROOT_SECRET")
ENV = os.Getenv("ENV")
DB_TYPE = os.Getenv("DB_TYPE")
DB_URL = os.Getenv("DB_URL")
SMTP_HOST = os.Getenv("SMTP_HOST")
SMTP_PORT = os.Getenv("SMTP_PORT")
SENDER_EMAIL = os.Getenv("SENDER_EMAIL")
SENDER_PASSWORD = os.Getenv("SENDER_PASSWORD")
JWT_SECRET = os.Getenv("JWT_SECRET")
JWT_TYPE = os.Getenv("JWT_TYPE")
FRONTEND_URL = strings.TrimSuffix(os.Getenv("FRONTEND_URL"), "/")
SERVER_URL = strings.TrimSuffix(os.Getenv("SERVER_URL"), "/")
PORT = os.Getenv("PORT")
REDIS_URL = os.Getenv("REDIS_URL")
COOKIE_NAME = os.Getenv("COOKIE_NAME")
GOOGLE_CLIENT_ID = os.Getenv("GOOGLE_CLIENT_ID")
GOOGLE_CLIENT_SECRET = os.Getenv("GOOGLE_CLIENT_SECRET")
GITHUB_CLIENT_ID = os.Getenv("GITHUB_CLIENT_ID")
GITHUB_CLIENT_SECRET = os.Getenv("GITHUB_CLIENT_SECRET")
// FACEBOOK_CLIENT_ID = os.Getenv("FACEBOOK_CLIENT_ID")
// FACEBOOK_CLIENT_SECRET = os.Getenv("FACEBOOK_CLIENT_SECRET")
FORGOT_PASSWORD_URI = strings.TrimPrefix(os.Getenv("FORGOT_PASSWORD_URI"), "/")
VERIFY_EMAIL_URI = strings.TrimPrefix(os.Getenv("VERIFY_EMAIL_URI"), "/")
if ROOT_SECRET == "" {
panic("Root admin secret is required")
}
if ENV == "" {
ENV = "production"
}
if ENV == "production" {
IS_PROD = true
} else {
IS_PROD = false
}
ParseArgs()
if DB_TYPE == "" {
DB_TYPE = enum.Postgres.String()
}
if DB_URL == "" {
DB_TYPE = "postgresql://localhost:5432/postgres"
}
if JWT_TYPE == "" {
JWT_TYPE = "HS256"
}
if COOKIE_NAME == "" {
COOKIE_NAME = "authorizer"
}
if SERVER_URL == "" {
SERVER_URL = "http://localhost:8080"
}
}

View File

@ -31,23 +31,22 @@ type manager struct {
var Mgr Manager var Mgr Manager
func init() { func InitDB() {
var db *gorm.DB var db *gorm.DB
var err error var err error
log.Println("=> from db:", constants.DB_TYPE, constants.DB_URL)
ormConfig := &gorm.Config{ ormConfig := &gorm.Config{
NamingStrategy: schema.NamingStrategy{ NamingStrategy: schema.NamingStrategy{
TablePrefix: "authorizer_", TablePrefix: "authorizer_",
}, },
} }
if constants.DB_TYPE == enum.Postgres.String() { if constants.DATABASE_TYPE == enum.Postgres.String() {
db, err = gorm.Open(postgres.Open(constants.DB_URL), ormConfig) db, err = gorm.Open(postgres.Open(constants.DATABASE_URL), ormConfig)
} }
if constants.DB_TYPE == enum.Mysql.String() { if constants.DATABASE_TYPE == enum.Mysql.String() {
db, err = gorm.Open(mysql.Open(constants.DB_URL), ormConfig) db, err = gorm.Open(mysql.Open(constants.DATABASE_URL), ormConfig)
} }
if constants.DB_TYPE == enum.Sqlite.String() { if constants.DATABASE_TYPE == enum.Sqlite.String() {
db, err = gorm.Open(sqlite.Open(constants.DB_URL), ormConfig) db, err = gorm.Open(sqlite.Open(constants.DATABASE_URL), ormConfig)
} }
if err != nil { if err != nil {

92
server/env.go Normal file
View File

@ -0,0 +1,92 @@
package main
import (
"flag"
"log"
"os"
"strings"
"github.com/authorizerdev/authorizer/server/constants"
"github.com/joho/godotenv"
)
// ParseArgs -> to parse the cli flag and get db url. This is useful with heroku button
func ParseArgs() {
dbURL := flag.String("database_url", "", "Database connection string")
dbType := flag.String("databse_type", "", "Database type, possible values are postgres,mysql,sqlit")
flag.Parse()
if *dbURL != "" {
constants.DATABASE_URL = *dbURL
}
if *dbType != "" {
constants.DATABASE_TYPE = *dbType
}
}
// InitEnv -> to initialize env and through error if required env are not present
func InitEnv() {
err := godotenv.Load()
if err != nil {
log.Println("Error loading .env file")
}
constants.ROOT_SECRET = os.Getenv("ROOT_SECRET")
constants.ENV = os.Getenv("ENV")
constants.DATABASE_TYPE = os.Getenv("DATABASE_TYPE")
constants.DATABASE_URL = os.Getenv("DATABASE_URL")
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.FRONTEND_URL = strings.TrimSuffix(os.Getenv("FRONTEND_URL"), "/")
constants.SERVER_URL = strings.TrimSuffix(os.Getenv("SERVER_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")
// FACEBOOK_CLIENT_ID = os.Getenv("FACEBOOK_CLIENT_ID")
// FACEBOOK_CLIENT_SECRET = os.Getenv("FACEBOOK_CLIENT_SECRET")
constants.FORGOT_PASSWORD_URI = strings.TrimPrefix(os.Getenv("FORGOT_PASSWORD_URI"), "/")
constants.VERIFY_EMAIL_URI = strings.TrimPrefix(os.Getenv("VERIFY_EMAIL_URI"), "/")
if constants.ROOT_SECRET == "" {
panic("Root admin secret is required")
}
if constants.ENV == "" {
constants.ENV = "production"
}
if constants.ENV == "production" {
constants.IS_PROD = true
os.Setenv("GIN_MODE", "release")
} else {
constants.IS_PROD = false
}
ParseArgs()
if constants.DATABASE_URL == "" {
panic("Database url is required")
}
if constants.DATABASE_TYPE == "" {
panic("Database type is required")
}
if constants.JWT_TYPE == "" {
constants.JWT_TYPE = "HS256"
}
if constants.COOKIE_NAME == "" {
constants.COOKIE_NAME = "authorizer"
}
if constants.SERVER_URL == "" {
constants.SERVER_URL = "http://localhost:8080"
}
}

View File

@ -39,7 +39,8 @@ type ResolverRoot interface {
Query() QueryResolver Query() QueryResolver
} }
type DirectiveRoot struct{} type DirectiveRoot struct {
}
type ComplexityRoot struct { type ComplexityRoot struct {
Error struct { Error struct {
@ -109,7 +110,6 @@ type MutationResolver interface {
ForgotPassword(ctx context.Context, params model.ForgotPasswordInput) (*model.Response, error) ForgotPassword(ctx context.Context, params model.ForgotPasswordInput) (*model.Response, error)
ResetPassword(ctx context.Context, params model.ResetPassowrdInput) (*model.Response, error) ResetPassword(ctx context.Context, params model.ResetPassowrdInput) (*model.Response, error)
} }
type QueryResolver interface { type QueryResolver interface {
Users(ctx context.Context) ([]*model.User, error) Users(ctx context.Context) ([]*model.User, error)
Token(ctx context.Context) (*model.LoginResponse, error) Token(ctx context.Context) (*model.LoginResponse, error)
@ -592,7 +592,7 @@ func (ec *executionContext) field_Mutation_forgotPassword_args(ctx context.Conte
var arg0 model.ForgotPasswordInput var arg0 model.ForgotPasswordInput
if tmp, ok := rawArgs["params"]; ok { if tmp, ok := rawArgs["params"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params")) ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params"))
arg0, err = ec.unmarshalNForgotPasswordInput2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐForgotPasswordInput(ctx, tmp) arg0, err = ec.unmarshalNForgotPasswordInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐForgotPasswordInput(ctx, tmp)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -607,7 +607,7 @@ func (ec *executionContext) field_Mutation_login_args(ctx context.Context, rawAr
var arg0 model.LoginInput var arg0 model.LoginInput
if tmp, ok := rawArgs["params"]; ok { if tmp, ok := rawArgs["params"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params")) ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params"))
arg0, err = ec.unmarshalNLoginInput2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐLoginInput(ctx, tmp) arg0, err = ec.unmarshalNLoginInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐLoginInput(ctx, tmp)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -622,7 +622,7 @@ func (ec *executionContext) field_Mutation_resendVerifyEmail_args(ctx context.Co
var arg0 model.ResendVerifyEmailInput var arg0 model.ResendVerifyEmailInput
if tmp, ok := rawArgs["params"]; ok { if tmp, ok := rawArgs["params"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params")) ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params"))
arg0, err = ec.unmarshalNResendVerifyEmailInput2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐResendVerifyEmailInput(ctx, tmp) arg0, err = ec.unmarshalNResendVerifyEmailInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐResendVerifyEmailInput(ctx, tmp)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -637,7 +637,7 @@ func (ec *executionContext) field_Mutation_resetPassword_args(ctx context.Contex
var arg0 model.ResetPassowrdInput var arg0 model.ResetPassowrdInput
if tmp, ok := rawArgs["params"]; ok { if tmp, ok := rawArgs["params"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params")) ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params"))
arg0, err = ec.unmarshalNResetPassowrdInput2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐResetPassowrdInput(ctx, tmp) arg0, err = ec.unmarshalNResetPassowrdInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐResetPassowrdInput(ctx, tmp)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -652,7 +652,7 @@ func (ec *executionContext) field_Mutation_signup_args(ctx context.Context, rawA
var arg0 model.SignUpInput var arg0 model.SignUpInput
if tmp, ok := rawArgs["params"]; ok { if tmp, ok := rawArgs["params"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params")) ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params"))
arg0, err = ec.unmarshalNSignUpInput2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐSignUpInput(ctx, tmp) arg0, err = ec.unmarshalNSignUpInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐSignUpInput(ctx, tmp)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -667,7 +667,7 @@ func (ec *executionContext) field_Mutation_updateProfile_args(ctx context.Contex
var arg0 model.UpdateProfileInput var arg0 model.UpdateProfileInput
if tmp, ok := rawArgs["params"]; ok { if tmp, ok := rawArgs["params"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params")) ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params"))
arg0, err = ec.unmarshalNUpdateProfileInput2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐUpdateProfileInput(ctx, tmp) arg0, err = ec.unmarshalNUpdateProfileInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐUpdateProfileInput(ctx, tmp)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -682,7 +682,7 @@ func (ec *executionContext) field_Mutation_verifyEmail_args(ctx context.Context,
var arg0 model.VerifyEmailInput var arg0 model.VerifyEmailInput
if tmp, ok := rawArgs["params"]; ok { if tmp, ok := rawArgs["params"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params")) ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params"))
arg0, err = ec.unmarshalNVerifyEmailInput2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐVerifyEmailInput(ctx, tmp) arg0, err = ec.unmarshalNVerifyEmailInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐVerifyEmailInput(ctx, tmp)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -942,7 +942,7 @@ func (ec *executionContext) _LoginResponse_user(ctx context.Context, field graph
} }
res := resTmp.(*model.User) res := resTmp.(*model.User)
fc.Result = res fc.Result = res
return ec.marshalOUser2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) return ec.marshalOUser2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐUser(ctx, field.Selections, res)
} }
func (ec *executionContext) _Mutation_signup(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { func (ec *executionContext) _Mutation_signup(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@ -984,7 +984,7 @@ func (ec *executionContext) _Mutation_signup(ctx context.Context, field graphql.
} }
res := resTmp.(*model.Response) res := resTmp.(*model.Response)
fc.Result = res fc.Result = res
return ec.marshalNResponse2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐResponse(ctx, field.Selections, res) return ec.marshalNResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐResponse(ctx, field.Selections, res)
} }
func (ec *executionContext) _Mutation_login(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { func (ec *executionContext) _Mutation_login(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@ -1026,7 +1026,7 @@ func (ec *executionContext) _Mutation_login(ctx context.Context, field graphql.C
} }
res := resTmp.(*model.LoginResponse) res := resTmp.(*model.LoginResponse)
fc.Result = res fc.Result = res
return ec.marshalNLoginResponse2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐLoginResponse(ctx, field.Selections, res) return ec.marshalNLoginResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐLoginResponse(ctx, field.Selections, res)
} }
func (ec *executionContext) _Mutation_logout(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { func (ec *executionContext) _Mutation_logout(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@ -1061,7 +1061,7 @@ func (ec *executionContext) _Mutation_logout(ctx context.Context, field graphql.
} }
res := resTmp.(*model.Response) res := resTmp.(*model.Response)
fc.Result = res fc.Result = res
return ec.marshalNResponse2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐResponse(ctx, field.Selections, res) 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_updateProfile(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@ -1103,7 +1103,7 @@ func (ec *executionContext) _Mutation_updateProfile(ctx context.Context, field g
} }
res := resTmp.(*model.Response) res := resTmp.(*model.Response)
fc.Result = res fc.Result = res
return ec.marshalNResponse2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐResponse(ctx, field.Selections, res) return ec.marshalNResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐResponse(ctx, field.Selections, res)
} }
func (ec *executionContext) _Mutation_verifyEmail(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { func (ec *executionContext) _Mutation_verifyEmail(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@ -1145,7 +1145,7 @@ func (ec *executionContext) _Mutation_verifyEmail(ctx context.Context, field gra
} }
res := resTmp.(*model.LoginResponse) res := resTmp.(*model.LoginResponse)
fc.Result = res fc.Result = res
return ec.marshalNLoginResponse2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐLoginResponse(ctx, field.Selections, res) return ec.marshalNLoginResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐLoginResponse(ctx, field.Selections, res)
} }
func (ec *executionContext) _Mutation_resendVerifyEmail(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { func (ec *executionContext) _Mutation_resendVerifyEmail(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@ -1187,7 +1187,7 @@ func (ec *executionContext) _Mutation_resendVerifyEmail(ctx context.Context, fie
} }
res := resTmp.(*model.Response) res := resTmp.(*model.Response)
fc.Result = res fc.Result = res
return ec.marshalNResponse2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐResponse(ctx, field.Selections, res) 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_forgotPassword(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@ -1229,7 +1229,7 @@ func (ec *executionContext) _Mutation_forgotPassword(ctx context.Context, field
} }
res := resTmp.(*model.Response) res := resTmp.(*model.Response)
fc.Result = res fc.Result = res
return ec.marshalNResponse2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐResponse(ctx, field.Selections, res) 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_resetPassword(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@ -1271,7 +1271,7 @@ func (ec *executionContext) _Mutation_resetPassword(ctx context.Context, field g
} }
res := resTmp.(*model.Response) res := resTmp.(*model.Response)
fc.Result = res fc.Result = res
return ec.marshalNResponse2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐResponse(ctx, field.Selections, res) return ec.marshalNResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐResponse(ctx, field.Selections, res)
} }
func (ec *executionContext) _Query_users(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { func (ec *executionContext) _Query_users(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@ -1306,7 +1306,7 @@ func (ec *executionContext) _Query_users(ctx context.Context, field graphql.Coll
} }
res := resTmp.([]*model.User) res := resTmp.([]*model.User)
fc.Result = res fc.Result = res
return ec.marshalNUser2ᚕᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐUserᚄ(ctx, field.Selections, 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) { func (ec *executionContext) _Query_token(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@ -1338,7 +1338,7 @@ func (ec *executionContext) _Query_token(ctx context.Context, field graphql.Coll
} }
res := resTmp.(*model.LoginResponse) res := resTmp.(*model.LoginResponse)
fc.Result = res fc.Result = res
return ec.marshalOLoginResponse2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐLoginResponse(ctx, field.Selections, res) return ec.marshalOLoginResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐLoginResponse(ctx, field.Selections, res)
} }
func (ec *executionContext) _Query_profile(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { func (ec *executionContext) _Query_profile(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@ -1373,7 +1373,7 @@ func (ec *executionContext) _Query_profile(ctx context.Context, field graphql.Co
} }
res := resTmp.(*model.User) res := resTmp.(*model.User)
fc.Result = res fc.Result = res
return ec.marshalNUser2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐUser(ctx, field.Selections, res) 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_verificationRequests(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@ -1408,7 +1408,7 @@ func (ec *executionContext) _Query_verificationRequests(ctx context.Context, fie
} }
res := resTmp.([]*model.VerificationRequest) res := resTmp.([]*model.VerificationRequest)
fc.Result = res fc.Result = res
return ec.marshalNVerificationRequest2ᚕᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐVerificationRequestᚄ(ctx, field.Selections, res) return ec.marshalNVerificationRequest2ᚕᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐVerificationRequestᚄ(ctx, field.Selections, res)
} }
func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@ -3130,7 +3130,7 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co
func (ec *executionContext) unmarshalInputForgotPasswordInput(ctx context.Context, obj interface{}) (model.ForgotPasswordInput, error) { func (ec *executionContext) unmarshalInputForgotPasswordInput(ctx context.Context, obj interface{}) (model.ForgotPasswordInput, error) {
var it model.ForgotPasswordInput var it model.ForgotPasswordInput
asMap := obj.(map[string]interface{}) var asMap = obj.(map[string]interface{})
for k, v := range asMap { for k, v := range asMap {
switch k { switch k {
@ -3150,7 +3150,7 @@ func (ec *executionContext) unmarshalInputForgotPasswordInput(ctx context.Contex
func (ec *executionContext) unmarshalInputLoginInput(ctx context.Context, obj interface{}) (model.LoginInput, error) { func (ec *executionContext) unmarshalInputLoginInput(ctx context.Context, obj interface{}) (model.LoginInput, error) {
var it model.LoginInput var it model.LoginInput
asMap := obj.(map[string]interface{}) var asMap = obj.(map[string]interface{})
for k, v := range asMap { for k, v := range asMap {
switch k { switch k {
@ -3178,7 +3178,7 @@ func (ec *executionContext) unmarshalInputLoginInput(ctx context.Context, obj in
func (ec *executionContext) unmarshalInputResendVerifyEmailInput(ctx context.Context, obj interface{}) (model.ResendVerifyEmailInput, error) { func (ec *executionContext) unmarshalInputResendVerifyEmailInput(ctx context.Context, obj interface{}) (model.ResendVerifyEmailInput, error) {
var it model.ResendVerifyEmailInput var it model.ResendVerifyEmailInput
asMap := obj.(map[string]interface{}) var asMap = obj.(map[string]interface{})
for k, v := range asMap { for k, v := range asMap {
switch k { switch k {
@ -3198,7 +3198,7 @@ func (ec *executionContext) unmarshalInputResendVerifyEmailInput(ctx context.Con
func (ec *executionContext) unmarshalInputResetPassowrdInput(ctx context.Context, obj interface{}) (model.ResetPassowrdInput, error) { func (ec *executionContext) unmarshalInputResetPassowrdInput(ctx context.Context, obj interface{}) (model.ResetPassowrdInput, error) {
var it model.ResetPassowrdInput var it model.ResetPassowrdInput
asMap := obj.(map[string]interface{}) var asMap = obj.(map[string]interface{})
for k, v := range asMap { for k, v := range asMap {
switch k { switch k {
@ -3234,7 +3234,7 @@ func (ec *executionContext) unmarshalInputResetPassowrdInput(ctx context.Context
func (ec *executionContext) unmarshalInputSignUpInput(ctx context.Context, obj interface{}) (model.SignUpInput, error) { func (ec *executionContext) unmarshalInputSignUpInput(ctx context.Context, obj interface{}) (model.SignUpInput, error) {
var it model.SignUpInput var it model.SignUpInput
asMap := obj.(map[string]interface{}) var asMap = obj.(map[string]interface{})
for k, v := range asMap { for k, v := range asMap {
switch k { switch k {
@ -3294,7 +3294,7 @@ func (ec *executionContext) unmarshalInputSignUpInput(ctx context.Context, obj i
func (ec *executionContext) unmarshalInputUpdateProfileInput(ctx context.Context, obj interface{}) (model.UpdateProfileInput, error) { func (ec *executionContext) unmarshalInputUpdateProfileInput(ctx context.Context, obj interface{}) (model.UpdateProfileInput, error) {
var it model.UpdateProfileInput var it model.UpdateProfileInput
asMap := obj.(map[string]interface{}) var asMap = obj.(map[string]interface{})
for k, v := range asMap { for k, v := range asMap {
switch k { switch k {
@ -3362,7 +3362,7 @@ func (ec *executionContext) unmarshalInputUpdateProfileInput(ctx context.Context
func (ec *executionContext) unmarshalInputVerifyEmailInput(ctx context.Context, obj interface{}) (model.VerifyEmailInput, error) { func (ec *executionContext) unmarshalInputVerifyEmailInput(ctx context.Context, obj interface{}) (model.VerifyEmailInput, error) {
var it model.VerifyEmailInput var it model.VerifyEmailInput
asMap := obj.(map[string]interface{}) var asMap = obj.(map[string]interface{})
for k, v := range asMap { for k, v := range asMap {
switch k { switch k {
@ -3977,7 +3977,7 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se
return res return res
} }
func (ec *executionContext) unmarshalNForgotPasswordInput2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐForgotPasswordInput(ctx context.Context, v interface{}) (model.ForgotPasswordInput, error) { func (ec *executionContext) unmarshalNForgotPasswordInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐForgotPasswordInput(ctx context.Context, v interface{}) (model.ForgotPasswordInput, error) {
res, err := ec.unmarshalInputForgotPasswordInput(ctx, v) res, err := ec.unmarshalInputForgotPasswordInput(ctx, v)
return res, graphql.ErrorOnPath(ctx, err) return res, graphql.ErrorOnPath(ctx, err)
} }
@ -3997,16 +3997,16 @@ func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.Selec
return res return res
} }
func (ec *executionContext) unmarshalNLoginInput2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐLoginInput(ctx context.Context, v interface{}) (model.LoginInput, error) { func (ec *executionContext) unmarshalNLoginInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐLoginInput(ctx context.Context, v interface{}) (model.LoginInput, error) {
res, err := ec.unmarshalInputLoginInput(ctx, v) res, err := ec.unmarshalInputLoginInput(ctx, v)
return res, graphql.ErrorOnPath(ctx, err) return res, graphql.ErrorOnPath(ctx, err)
} }
func (ec *executionContext) marshalNLoginResponse2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐLoginResponse(ctx context.Context, sel ast.SelectionSet, v model.LoginResponse) graphql.Marshaler { func (ec *executionContext) marshalNLoginResponse2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐLoginResponse(ctx context.Context, sel ast.SelectionSet, v model.LoginResponse) graphql.Marshaler {
return ec._LoginResponse(ctx, sel, &v) return ec._LoginResponse(ctx, sel, &v)
} }
func (ec *executionContext) marshalNLoginResponse2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐLoginResponse(ctx context.Context, sel ast.SelectionSet, v *model.LoginResponse) graphql.Marshaler { func (ec *executionContext) marshalNLoginResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐLoginResponse(ctx context.Context, sel ast.SelectionSet, v *model.LoginResponse) graphql.Marshaler {
if v == nil { if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "must not be null") ec.Errorf(ctx, "must not be null")
@ -4016,21 +4016,21 @@ func (ec *executionContext) marshalNLoginResponse2ᚖgithubᚗcomᚋyauthdevᚋy
return ec._LoginResponse(ctx, sel, v) return ec._LoginResponse(ctx, sel, v)
} }
func (ec *executionContext) unmarshalNResendVerifyEmailInput2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐResendVerifyEmailInput(ctx context.Context, v interface{}) (model.ResendVerifyEmailInput, error) { func (ec *executionContext) unmarshalNResendVerifyEmailInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐResendVerifyEmailInput(ctx context.Context, v interface{}) (model.ResendVerifyEmailInput, error) {
res, err := ec.unmarshalInputResendVerifyEmailInput(ctx, v) res, err := ec.unmarshalInputResendVerifyEmailInput(ctx, v)
return res, graphql.ErrorOnPath(ctx, err) return res, graphql.ErrorOnPath(ctx, err)
} }
func (ec *executionContext) unmarshalNResetPassowrdInput2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐResetPassowrdInput(ctx context.Context, v interface{}) (model.ResetPassowrdInput, error) { func (ec *executionContext) unmarshalNResetPassowrdInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐResetPassowrdInput(ctx context.Context, v interface{}) (model.ResetPassowrdInput, error) {
res, err := ec.unmarshalInputResetPassowrdInput(ctx, v) res, err := ec.unmarshalInputResetPassowrdInput(ctx, v)
return res, graphql.ErrorOnPath(ctx, err) return res, graphql.ErrorOnPath(ctx, err)
} }
func (ec *executionContext) marshalNResponse2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐResponse(ctx context.Context, sel ast.SelectionSet, v model.Response) graphql.Marshaler { func (ec *executionContext) marshalNResponse2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐResponse(ctx context.Context, sel ast.SelectionSet, v model.Response) graphql.Marshaler {
return ec._Response(ctx, sel, &v) return ec._Response(ctx, sel, &v)
} }
func (ec *executionContext) marshalNResponse2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐResponse(ctx context.Context, sel ast.SelectionSet, v *model.Response) graphql.Marshaler { func (ec *executionContext) marshalNResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐResponse(ctx context.Context, sel ast.SelectionSet, v *model.Response) graphql.Marshaler {
if v == nil { if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "must not be null") ec.Errorf(ctx, "must not be null")
@ -4040,7 +4040,7 @@ func (ec *executionContext) marshalNResponse2ᚖgithubᚗcomᚋyauthdevᚋyauth
return ec._Response(ctx, sel, v) return ec._Response(ctx, sel, v)
} }
func (ec *executionContext) unmarshalNSignUpInput2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐSignUpInput(ctx context.Context, v interface{}) (model.SignUpInput, error) { func (ec *executionContext) unmarshalNSignUpInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐSignUpInput(ctx context.Context, v interface{}) (model.SignUpInput, error) {
res, err := ec.unmarshalInputSignUpInput(ctx, v) res, err := ec.unmarshalInputSignUpInput(ctx, v)
return res, graphql.ErrorOnPath(ctx, err) return res, graphql.ErrorOnPath(ctx, err)
} }
@ -4060,16 +4060,16 @@ func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.S
return res return res
} }
func (ec *executionContext) unmarshalNUpdateProfileInput2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐUpdateProfileInput(ctx context.Context, v interface{}) (model.UpdateProfileInput, error) { func (ec *executionContext) unmarshalNUpdateProfileInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐUpdateProfileInput(ctx context.Context, v interface{}) (model.UpdateProfileInput, error) {
res, err := ec.unmarshalInputUpdateProfileInput(ctx, v) res, err := ec.unmarshalInputUpdateProfileInput(ctx, v)
return res, graphql.ErrorOnPath(ctx, err) return res, graphql.ErrorOnPath(ctx, err)
} }
func (ec *executionContext) marshalNUser2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v model.User) graphql.Marshaler { 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) return ec._User(ctx, sel, &v)
} }
func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐUserᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.User) graphql.Marshaler { func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐUserᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.User) graphql.Marshaler {
ret := make(graphql.Array, len(v)) ret := make(graphql.Array, len(v))
var wg sync.WaitGroup var wg sync.WaitGroup
isLen1 := len(v) == 1 isLen1 := len(v) == 1
@ -4093,7 +4093,7 @@ func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋyauthdevᚋyauth
if !isLen1 { if !isLen1 {
defer wg.Done() defer wg.Done()
} }
ret[i] = ec.marshalNUser2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐUser(ctx, sel, v[i]) ret[i] = ec.marshalNUser2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐUser(ctx, sel, v[i])
} }
if isLen1 { if isLen1 {
f(i) f(i)
@ -4106,7 +4106,7 @@ func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋyauthdevᚋyauth
return ret return ret
} }
func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler {
if v == nil { if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "must not be null") ec.Errorf(ctx, "must not be null")
@ -4116,7 +4116,7 @@ func (ec *executionContext) marshalNUser2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋse
return ec._User(ctx, sel, v) return ec._User(ctx, sel, v)
} }
func (ec *executionContext) marshalNVerificationRequest2ᚕᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐVerificationRequestᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.VerificationRequest) graphql.Marshaler { func (ec *executionContext) marshalNVerificationRequest2ᚕᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐVerificationRequestᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.VerificationRequest) graphql.Marshaler {
ret := make(graphql.Array, len(v)) ret := make(graphql.Array, len(v))
var wg sync.WaitGroup var wg sync.WaitGroup
isLen1 := len(v) == 1 isLen1 := len(v) == 1
@ -4140,7 +4140,7 @@ func (ec *executionContext) marshalNVerificationRequest2ᚕᚖgithubᚗcomᚋyau
if !isLen1 { if !isLen1 {
defer wg.Done() defer wg.Done()
} }
ret[i] = ec.marshalNVerificationRequest2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐVerificationRequest(ctx, sel, v[i]) ret[i] = ec.marshalNVerificationRequest2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐVerificationRequest(ctx, sel, v[i])
} }
if isLen1 { if isLen1 {
f(i) f(i)
@ -4153,7 +4153,7 @@ func (ec *executionContext) marshalNVerificationRequest2ᚕᚖgithubᚗcomᚋyau
return ret return ret
} }
func (ec *executionContext) marshalNVerificationRequest2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐVerificationRequest(ctx context.Context, sel ast.SelectionSet, v *model.VerificationRequest) graphql.Marshaler { func (ec *executionContext) marshalNVerificationRequest2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐVerificationRequest(ctx context.Context, sel ast.SelectionSet, v *model.VerificationRequest) graphql.Marshaler {
if v == nil { if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "must not be null") ec.Errorf(ctx, "must not be null")
@ -4163,7 +4163,7 @@ func (ec *executionContext) marshalNVerificationRequest2ᚖgithubᚗcomᚋyauthd
return ec._VerificationRequest(ctx, sel, v) return ec._VerificationRequest(ctx, sel, v)
} }
func (ec *executionContext) unmarshalNVerifyEmailInput2githubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐVerifyEmailInput(ctx context.Context, v interface{}) (model.VerifyEmailInput, error) { func (ec *executionContext) unmarshalNVerifyEmailInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐVerifyEmailInput(ctx context.Context, v interface{}) (model.VerifyEmailInput, error) {
res, err := ec.unmarshalInputVerifyEmailInput(ctx, v) res, err := ec.unmarshalInputVerifyEmailInput(ctx, v)
return res, graphql.ErrorOnPath(ctx, err) return res, graphql.ErrorOnPath(ctx, err)
} }
@ -4436,7 +4436,7 @@ func (ec *executionContext) marshalOInt642ᚖint64(ctx context.Context, sel ast.
return graphql.MarshalInt64(*v) return graphql.MarshalInt64(*v)
} }
func (ec *executionContext) marshalOLoginResponse2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐLoginResponse(ctx context.Context, sel ast.SelectionSet, v *model.LoginResponse) graphql.Marshaler { func (ec *executionContext) marshalOLoginResponse2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐLoginResponse(ctx context.Context, sel ast.SelectionSet, v *model.LoginResponse) graphql.Marshaler {
if v == nil { if v == nil {
return graphql.Null return graphql.Null
} }
@ -4467,7 +4467,7 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as
return graphql.MarshalString(*v) return graphql.MarshalString(*v)
} }
func (ec *executionContext) marshalOUser2ᚖgithubᚗcomᚋyauthdevᚋyauthᚋserverᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler { func (ec *executionContext) marshalOUser2ᚖgithubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler {
if v == nil { if v == nil {
return graphql.Null return graphql.Null
} }

View File

@ -65,7 +65,5 @@ func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResol
// Query returns generated.QueryResolver implementation. // Query returns generated.QueryResolver implementation.
func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} }
type ( type mutationResolver struct{ *Resolver }
mutationResolver struct{ *Resolver } type queryResolver struct{ *Resolver }
queryResolver struct{ *Resolver }
)

View File

@ -2,11 +2,12 @@ package main
import ( import (
"context" "context"
"log"
"github.com/authorizerdev/authorizer/server/db"
"github.com/authorizerdev/authorizer/server/enum" "github.com/authorizerdev/authorizer/server/enum"
"github.com/authorizerdev/authorizer/server/handlers" "github.com/authorizerdev/authorizer/server/handlers"
"github.com/authorizerdev/authorizer/server/oauth" "github.com/authorizerdev/authorizer/server/oauth"
"github.com/authorizerdev/authorizer/server/session"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
@ -21,7 +22,6 @@ func GinContextToContextMiddleware() gin.HandlerFunc {
func CORSMiddleware() gin.HandlerFunc { func CORSMiddleware() gin.HandlerFunc {
return func(c *gin.Context) { return func(c *gin.Context) {
origin := c.Request.Header.Get("Origin") origin := c.Request.Header.Get("Origin")
log.Println("-> origin", origin)
c.Writer.Header().Set("Access-Control-Allow-Origin", origin) c.Writer.Header().Set("Access-Control-Allow-Origin", origin)
c.Writer.Header().Set("Access-Control-Allow-Credentials", "true") c.Writer.Header().Set("Access-Control-Allow-Credentials", "true")
c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With") c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With")
@ -37,6 +37,10 @@ func CORSMiddleware() gin.HandlerFunc {
} }
func main() { func main() {
InitEnv()
db.InitDB()
session.InitSession()
r := gin.Default() r := gin.Default()
r.Use(GinContextToContextMiddleware()) r.Use(GinContextToContextMiddleware())
r.Use(CORSMiddleware()) r.Use(CORSMiddleware())

View File

@ -13,21 +13,21 @@ type RedisStore struct {
} }
func (c *RedisStore) AddToken(userId, token string) { func (c *RedisStore) AddToken(userId, token string) {
err := c.store.Set(c.ctx, "yauth_"+userId, token, 0).Err() err := c.store.Set(c.ctx, "authorizer_"+userId, token, 0).Err()
if err != nil { if err != nil {
log.Fatalln("Error saving redis token:", err) log.Fatalln("Error saving redis token:", err)
} }
} }
func (c *RedisStore) DeleteToken(userId string) { func (c *RedisStore) DeleteToken(userId string) {
err := c.store.Del(c.ctx, "yauth_"+userId).Err() err := c.store.Del(c.ctx, "authorizer_"+userId).Err()
if err != nil { if err != nil {
log.Fatalln("Error deleting redis token:", err) log.Fatalln("Error deleting redis token:", err)
} }
} }
func (c *RedisStore) ClearStore() { func (c *RedisStore) ClearStore() {
err := c.store.Del(c.ctx, "yauth_*").Err() err := c.store.Del(c.ctx, "authorizer_*").Err()
if err != nil { if err != nil {
log.Fatalln("Error clearing redis store:", err) log.Fatalln("Error clearing redis store:", err)
} }
@ -35,7 +35,7 @@ func (c *RedisStore) ClearStore() {
func (c *RedisStore) GetToken(userId string) string { func (c *RedisStore) GetToken(userId string) string {
token := "" token := ""
token, err := c.store.Get(c.ctx, "yauth_"+userId).Result() token, err := c.store.Get(c.ctx, "authorizer_"+userId).Result()
if err != nil { if err != nil {
log.Println("Error getting token from redis store:", err) log.Println("Error getting token from redis store:", err)
} }

View File

@ -53,7 +53,7 @@ func ClearStore() {
} }
} }
func init() { func InitSession() {
if constants.REDIS_URL != "" { if constants.REDIS_URL != "" {
log.Println("Using redis store to save sessions") log.Println("Using redis store to save sessions")
opt, err := redis.ParseURL(constants.REDIS_URL) opt, err := redis.ParseURL(constants.REDIS_URL)

View File

@ -13,9 +13,6 @@ func SetCookie(gc *gin.Context, token string) {
secure := true secure := true
httpOnly := true httpOnly := true
if !constants.IS_PROD {
secure = false
}
u, err := url.Parse(constants.SERVER_URL) u, err := url.Parse(constants.SERVER_URL)
if err != nil { if err != nil {
log.Println("error getting server host") log.Println("error getting server host")

View File

@ -6,7 +6,7 @@ import (
) )
func IsSuperAdmin(gc *gin.Context) bool { func IsSuperAdmin(gc *gin.Context) bool {
secret := gc.Request.Header.Get("x-yauth-admin-secret") secret := gc.Request.Header.Get("x-authorizer-root-secret")
if secret == "" { if secret == "" {
return false return false
} }