Merge branch 'main' of https://github.com/authorizerdev/authorizer into feat/dashboard
This commit is contained in:
commit
ca716ec1dd
|
@ -10,8 +10,9 @@ type EnvConst struct {
|
||||||
DATABASE_NAME string
|
DATABASE_NAME string
|
||||||
SMTP_HOST string
|
SMTP_HOST string
|
||||||
SMTP_PORT string
|
SMTP_PORT string
|
||||||
|
SMTP_PASSWORD string
|
||||||
|
SMTP_USERNAME string
|
||||||
SENDER_EMAIL string
|
SENDER_EMAIL string
|
||||||
SENDER_PASSWORD string
|
|
||||||
JWT_TYPE string
|
JWT_TYPE string
|
||||||
JWT_SECRET string
|
JWT_SECRET string
|
||||||
ALLOWED_ORIGINS []string
|
ALLOWED_ORIGINS []string
|
||||||
|
|
|
@ -27,19 +27,18 @@ type Sender struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSender() Sender {
|
func NewSender() Sender {
|
||||||
return Sender{User: constants.EnvData.SENDER_EMAIL, Password: constants.EnvData.SENDER_PASSWORD}
|
return Sender{User: constants.EnvData.SMTP_USERNAME, Password: constants.EnvData.SMTP_PASSWORD}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sender Sender) SendMail(Dest []string, Subject, bodyMessage string) error {
|
func (sender Sender) SendMail(Dest []string, Subject, bodyMessage string) error {
|
||||||
msg := "From: " + sender.User + "\n" +
|
msg := "From: " + constants.EnvData.SENDER_EMAIL + "\n" +
|
||||||
"To: " + strings.Join(Dest, ",") + "\n" +
|
"To: " + strings.Join(Dest, ",") + "\n" +
|
||||||
"Subject: " + Subject + "\n" + bodyMessage
|
"Subject: " + Subject + "\n" + bodyMessage
|
||||||
|
|
||||||
err := smtp.SendMail(constants.EnvData.SMTP_HOST+":"+constants.EnvData.SMTP_PORT,
|
err := smtp.SendMail(constants.EnvData.SMTP_HOST+":"+constants.EnvData.SMTP_PORT,
|
||||||
smtp.PlainAuth("", sender.User, sender.Password, constants.EnvData.SMTP_HOST),
|
smtp.PlainAuth("", sender.User, sender.Password, constants.EnvData.SMTP_HOST),
|
||||||
sender.User, Dest, []byte(msg))
|
constants.EnvData.SENDER_EMAIL, Dest, []byte(msg))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
log.Printf("smtp error: %s", err)
|
log.Printf("smtp error: %s", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
14
server/env/env.go
vendored
14
server/env/env.go
vendored
|
@ -92,12 +92,16 @@ func InitEnv() {
|
||||||
constants.EnvData.SMTP_PORT = os.Getenv("SMTP_PORT")
|
constants.EnvData.SMTP_PORT = os.Getenv("SMTP_PORT")
|
||||||
}
|
}
|
||||||
|
|
||||||
if constants.EnvData.SENDER_EMAIL == "" {
|
if constants.EnvData.SMTP_USERNAME == "" {
|
||||||
constants.EnvData.SENDER_EMAIL = os.Getenv("SENDER_EMAIL")
|
constants.EnvData.SMTP_USERNAME = os.Getenv("SMTP_USERNAME")
|
||||||
}
|
}
|
||||||
|
|
||||||
if constants.EnvData.SENDER_PASSWORD == "" {
|
if constants.EnvData.SMTP_PASSWORD == "" {
|
||||||
constants.EnvData.SENDER_PASSWORD = os.Getenv("SENDER_PASSWORD")
|
constants.EnvData.SMTP_PASSWORD = os.Getenv("SMTP_PASSWORD")
|
||||||
|
}
|
||||||
|
|
||||||
|
if constants.EnvData.SENDER_EMAIL == "" {
|
||||||
|
constants.EnvData.SENDER_EMAIL = os.Getenv("SENDER_EMAIL")
|
||||||
}
|
}
|
||||||
|
|
||||||
if constants.EnvData.JWT_SECRET == "" {
|
if constants.EnvData.JWT_SECRET == "" {
|
||||||
|
@ -181,7 +185,7 @@ func InitEnv() {
|
||||||
constants.EnvData.DISABLE_MAGIC_LINK_LOGIN = os.Getenv("DISABLE_MAGIC_LINK_LOGIN") == "true"
|
constants.EnvData.DISABLE_MAGIC_LINK_LOGIN = os.Getenv("DISABLE_MAGIC_LINK_LOGIN") == "true"
|
||||||
constants.EnvData.DISABLE_LOGIN_PAGE = os.Getenv("DISABLE_LOGIN_PAGE") == "true"
|
constants.EnvData.DISABLE_LOGIN_PAGE = os.Getenv("DISABLE_LOGIN_PAGE") == "true"
|
||||||
|
|
||||||
if constants.EnvData.SMTP_HOST == "" || constants.EnvData.SENDER_EMAIL == "" || constants.EnvData.SENDER_PASSWORD == "" {
|
if constants.EnvData.SMTP_HOST == "" || constants.EnvData.SMTP_USERNAME == "" || constants.EnvData.SMTP_PASSWORD == "" || constants.EnvData.SENDER_EMAIL == "" {
|
||||||
constants.EnvData.DISABLE_EMAIL_VERIFICATION = true
|
constants.EnvData.DISABLE_EMAIL_VERIFICATION = true
|
||||||
constants.EnvData.DISABLE_MAGIC_LINK_LOGIN = true
|
constants.EnvData.DISABLE_MAGIC_LINK_LOGIN = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,9 +85,10 @@ type ComplexityRoot struct {
|
||||||
ResetPasswordURL func(childComplexity int) int
|
ResetPasswordURL func(childComplexity int) int
|
||||||
Roles func(childComplexity int) int
|
Roles func(childComplexity int) int
|
||||||
SMTPHost func(childComplexity int) int
|
SMTPHost func(childComplexity int) int
|
||||||
|
SMTPPassword func(childComplexity int) int
|
||||||
SMTPPort func(childComplexity int) int
|
SMTPPort func(childComplexity int) int
|
||||||
|
SMTPUsername func(childComplexity int) int
|
||||||
SenderEmail func(childComplexity int) int
|
SenderEmail func(childComplexity int) int
|
||||||
SenderPassword func(childComplexity int) int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Error struct {
|
Error struct {
|
||||||
|
@ -453,6 +454,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
||||||
|
|
||||||
return e.complexity.Config.SMTPHost(childComplexity), true
|
return e.complexity.Config.SMTPHost(childComplexity), true
|
||||||
|
|
||||||
|
case "Config.SMTP_PASSWORD":
|
||||||
|
if e.complexity.Config.SMTPPassword == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return e.complexity.Config.SMTPPassword(childComplexity), true
|
||||||
|
|
||||||
case "Config.SMTP_PORT":
|
case "Config.SMTP_PORT":
|
||||||
if e.complexity.Config.SMTPPort == nil {
|
if e.complexity.Config.SMTPPort == nil {
|
||||||
break
|
break
|
||||||
|
@ -460,6 +468,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
||||||
|
|
||||||
return e.complexity.Config.SMTPPort(childComplexity), true
|
return e.complexity.Config.SMTPPort(childComplexity), true
|
||||||
|
|
||||||
|
case "Config.SMTP_USERNAME":
|
||||||
|
if e.complexity.Config.SMTPUsername == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return e.complexity.Config.SMTPUsername(childComplexity), true
|
||||||
|
|
||||||
case "Config.SENDER_EMAIL":
|
case "Config.SENDER_EMAIL":
|
||||||
if e.complexity.Config.SenderEmail == nil {
|
if e.complexity.Config.SenderEmail == nil {
|
||||||
break
|
break
|
||||||
|
@ -467,13 +482,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
||||||
|
|
||||||
return e.complexity.Config.SenderEmail(childComplexity), true
|
return e.complexity.Config.SenderEmail(childComplexity), true
|
||||||
|
|
||||||
case "Config.SENDER_PASSWORD":
|
|
||||||
if e.complexity.Config.SenderPassword == nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
return e.complexity.Config.SenderPassword(childComplexity), true
|
|
||||||
|
|
||||||
case "Error.message":
|
case "Error.message":
|
||||||
if e.complexity.Error.Message == nil {
|
if e.complexity.Error.Message == nil {
|
||||||
break
|
break
|
||||||
|
@ -1064,8 +1072,9 @@ type Config {
|
||||||
DATABASE_NAME: String
|
DATABASE_NAME: String
|
||||||
SMTP_HOST: String
|
SMTP_HOST: String
|
||||||
SMTP_PORT: String
|
SMTP_PORT: String
|
||||||
|
SMTP_USERNAME: String
|
||||||
|
SMTP_PASSWORD: String
|
||||||
SENDER_EMAIL: String
|
SENDER_EMAIL: String
|
||||||
SENDER_PASSWORD: String
|
|
||||||
JWT_TYPE: String
|
JWT_TYPE: String
|
||||||
JWT_SECRET: String
|
JWT_SECRET: String
|
||||||
ALLOWED_ORIGINS: [String!]
|
ALLOWED_ORIGINS: [String!]
|
||||||
|
@ -1886,6 +1895,70 @@ func (ec *executionContext) _Config_SMTP_PORT(ctx context.Context, field graphql
|
||||||
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
|
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) _Config_SMTP_USERNAME(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) {
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
ec.Error(ctx, ec.Recover(ctx, r))
|
||||||
|
ret = graphql.Null
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
fc := &graphql.FieldContext{
|
||||||
|
Object: "Config",
|
||||||
|
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.SMTPUsername, 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) _Config_SMTP_PASSWORD(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) {
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
ec.Error(ctx, ec.Recover(ctx, r))
|
||||||
|
ret = graphql.Null
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
fc := &graphql.FieldContext{
|
||||||
|
Object: "Config",
|
||||||
|
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.SMTPPassword, 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) _Config_SENDER_EMAIL(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) {
|
func (ec *executionContext) _Config_SENDER_EMAIL(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
|
@ -1918,38 +1991,6 @@ func (ec *executionContext) _Config_SENDER_EMAIL(ctx context.Context, field grap
|
||||||
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
|
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) _Config_SENDER_PASSWORD(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) {
|
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil {
|
|
||||||
ec.Error(ctx, ec.Recover(ctx, r))
|
|
||||||
ret = graphql.Null
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
fc := &graphql.FieldContext{
|
|
||||||
Object: "Config",
|
|
||||||
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.SenderPassword, 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) _Config_JWT_TYPE(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) {
|
func (ec *executionContext) _Config_JWT_TYPE(ctx context.Context, field graphql.CollectedField, obj *model.Config) (ret graphql.Marshaler) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
|
@ -6797,10 +6838,12 @@ func (ec *executionContext) _Config(ctx context.Context, sel ast.SelectionSet, o
|
||||||
out.Values[i] = ec._Config_SMTP_HOST(ctx, field, obj)
|
out.Values[i] = ec._Config_SMTP_HOST(ctx, field, obj)
|
||||||
case "SMTP_PORT":
|
case "SMTP_PORT":
|
||||||
out.Values[i] = ec._Config_SMTP_PORT(ctx, field, obj)
|
out.Values[i] = ec._Config_SMTP_PORT(ctx, field, obj)
|
||||||
|
case "SMTP_USERNAME":
|
||||||
|
out.Values[i] = ec._Config_SMTP_USERNAME(ctx, field, obj)
|
||||||
|
case "SMTP_PASSWORD":
|
||||||
|
out.Values[i] = ec._Config_SMTP_PASSWORD(ctx, field, obj)
|
||||||
case "SENDER_EMAIL":
|
case "SENDER_EMAIL":
|
||||||
out.Values[i] = ec._Config_SENDER_EMAIL(ctx, field, obj)
|
out.Values[i] = ec._Config_SENDER_EMAIL(ctx, field, obj)
|
||||||
case "SENDER_PASSWORD":
|
|
||||||
out.Values[i] = ec._Config_SENDER_PASSWORD(ctx, field, obj)
|
|
||||||
case "JWT_TYPE":
|
case "JWT_TYPE":
|
||||||
out.Values[i] = ec._Config_JWT_TYPE(ctx, field, obj)
|
out.Values[i] = ec._Config_JWT_TYPE(ctx, field, obj)
|
||||||
case "JWT_SECRET":
|
case "JWT_SECRET":
|
||||||
|
|
|
@ -25,8 +25,9 @@ type Config struct {
|
||||||
DatabaseName *string `json:"DATABASE_NAME"`
|
DatabaseName *string `json:"DATABASE_NAME"`
|
||||||
SMTPHost *string `json:"SMTP_HOST"`
|
SMTPHost *string `json:"SMTP_HOST"`
|
||||||
SMTPPort *string `json:"SMTP_PORT"`
|
SMTPPort *string `json:"SMTP_PORT"`
|
||||||
|
SMTPUsername *string `json:"SMTP_USERNAME"`
|
||||||
|
SMTPPassword *string `json:"SMTP_PASSWORD"`
|
||||||
SenderEmail *string `json:"SENDER_EMAIL"`
|
SenderEmail *string `json:"SENDER_EMAIL"`
|
||||||
SenderPassword *string `json:"SENDER_PASSWORD"`
|
|
||||||
JwtType *string `json:"JWT_TYPE"`
|
JwtType *string `json:"JWT_TYPE"`
|
||||||
JwtSecret *string `json:"JWT_SECRET"`
|
JwtSecret *string `json:"JWT_SECRET"`
|
||||||
AllowedOrigins []string `json:"ALLOWED_ORIGINS"`
|
AllowedOrigins []string `json:"ALLOWED_ORIGINS"`
|
||||||
|
|
|
@ -74,8 +74,9 @@ type Config {
|
||||||
DATABASE_NAME: String
|
DATABASE_NAME: String
|
||||||
SMTP_HOST: String
|
SMTP_HOST: String
|
||||||
SMTP_PORT: String
|
SMTP_PORT: String
|
||||||
|
SMTP_USERNAME: String
|
||||||
|
SMTP_PASSWORD: String
|
||||||
SENDER_EMAIL: String
|
SENDER_EMAIL: String
|
||||||
SENDER_PASSWORD: String
|
|
||||||
JWT_TYPE: String
|
JWT_TYPE: String
|
||||||
JWT_SECRET: String
|
JWT_SECRET: String
|
||||||
ALLOWED_ORIGINS: [String!]
|
ALLOWED_ORIGINS: [String!]
|
||||||
|
|
|
@ -101,7 +101,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 }
|
|
||||||
)
|
|
||||||
|
|
|
@ -28,8 +28,9 @@ func ConfigResolver(ctx context.Context) (*model.Config, error) {
|
||||||
DatabaseName: &constants.EnvData.DATABASE_NAME,
|
DatabaseName: &constants.EnvData.DATABASE_NAME,
|
||||||
SMTPHost: &constants.EnvData.SMTP_HOST,
|
SMTPHost: &constants.EnvData.SMTP_HOST,
|
||||||
SMTPPort: &constants.EnvData.SMTP_PORT,
|
SMTPPort: &constants.EnvData.SMTP_PORT,
|
||||||
|
SMTPPassword: &constants.EnvData.SMTP_PASSWORD,
|
||||||
|
SMTPUsername: &constants.EnvData.SMTP_USERNAME,
|
||||||
SenderEmail: &constants.EnvData.SENDER_EMAIL,
|
SenderEmail: &constants.EnvData.SENDER_EMAIL,
|
||||||
SenderPassword: &constants.EnvData.SENDER_PASSWORD,
|
|
||||||
JwtType: &constants.EnvData.JWT_TYPE,
|
JwtType: &constants.EnvData.JWT_TYPE,
|
||||||
JwtSecret: &constants.EnvData.JWT_SECRET,
|
JwtSecret: &constants.EnvData.JWT_SECRET,
|
||||||
AllowedOrigins: constants.EnvData.ALLOWED_ORIGINS,
|
AllowedOrigins: constants.EnvData.ALLOWED_ORIGINS,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user