* return variable to snake case
* import refactoring
This commit is contained in:
lemonScaletech 2023-09-13 14:14:56 +05:30
parent 96fdc38c3c
commit af66958b5d
8 changed files with 103 additions and 242 deletions

View File

@ -45,18 +45,16 @@ type DirectiveRoot struct {
type ComplexityRoot struct { type ComplexityRoot struct {
AuthResponse struct { AuthResponse struct {
AccessToken func(childComplexity int) int AccessToken func(childComplexity int) int
ExpiresIn func(childComplexity int) int ExpiresIn func(childComplexity int) int
IDToken func(childComplexity int) int IDToken func(childComplexity int) int
Message func(childComplexity int) int Message func(childComplexity int) int
RefreshToken func(childComplexity int) int RefreshToken func(childComplexity int) int
ShouldShowEmailOtpScreen func(childComplexity int) int ShouldShowEmailOtpScreen func(childComplexity int) int
ShouldShowMobileOtpScreen func(childComplexity int) int ShouldShowMobileOtpScreen func(childComplexity int) int
ShouldShowMobileTotpScreen func(childComplexity int) int TotpBase64URL func(childComplexity int) int
ShouldShowTotpScreen func(childComplexity int) int TotpToken func(childComplexity int) int
TokenTotp func(childComplexity int) int User func(childComplexity int) int
TotpBase64url func(childComplexity int) int
User func(childComplexity int) int
} }
EmailTemplate struct { EmailTemplate struct {
@ -455,33 +453,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.AuthResponse.ShouldShowMobileOtpScreen(childComplexity), true return e.complexity.AuthResponse.ShouldShowMobileOtpScreen(childComplexity), true
case "AuthResponse.should_show_mobile_totp_screen": case "AuthResponse.totp_base64_url":
if e.complexity.AuthResponse.ShouldShowMobileTotpScreen == nil { if e.complexity.AuthResponse.TotpBase64URL == nil {
break break
} }
return e.complexity.AuthResponse.ShouldShowMobileTotpScreen(childComplexity), true return e.complexity.AuthResponse.TotpBase64URL(childComplexity), true
case "AuthResponse.should_show_totp_screen": case "AuthResponse.totp_token":
if e.complexity.AuthResponse.ShouldShowTotpScreen == nil { if e.complexity.AuthResponse.TotpToken == nil {
break break
} }
return e.complexity.AuthResponse.ShouldShowTotpScreen(childComplexity), true return e.complexity.AuthResponse.TotpToken(childComplexity), true
case "AuthResponse.tokenTOTP":
if e.complexity.AuthResponse.TokenTotp == nil {
break
}
return e.complexity.AuthResponse.TokenTotp(childComplexity), true
case "AuthResponse.totpBase64URL":
if e.complexity.AuthResponse.TotpBase64url == nil {
break
}
return e.complexity.AuthResponse.TotpBase64url(childComplexity), true
case "AuthResponse.user": case "AuthResponse.user":
if e.complexity.AuthResponse.User == nil { if e.complexity.AuthResponse.User == nil {
@ -2368,15 +2352,13 @@ type AuthResponse {
message: String! message: String!
should_show_email_otp_screen: Boolean should_show_email_otp_screen: Boolean
should_show_mobile_otp_screen: Boolean should_show_mobile_otp_screen: Boolean
should_show_mobile_totp_screen: Boolean
should_show_totp_screen: Boolean
access_token: String access_token: String
id_token: String id_token: String
refresh_token: String refresh_token: String
expires_in: Int64 expires_in: Int64
user: User user: User
totpBase64URL: String totp_base64_url: String
tokenTOTP: String totp_token: String
} }
type Response { type Response {
@ -3700,88 +3682,6 @@ func (ec *executionContext) fieldContext_AuthResponse_should_show_mobile_otp_scr
return fc, nil return fc, nil
} }
func (ec *executionContext) _AuthResponse_should_show_mobile_totp_screen(ctx context.Context, field graphql.CollectedField, obj *model.AuthResponse) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_AuthResponse_should_show_mobile_totp_screen(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.ShouldShowMobileTotpScreen, 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) fieldContext_AuthResponse_should_show_mobile_totp_screen(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "AuthResponse",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type Boolean does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _AuthResponse_should_show_totp_screen(ctx context.Context, field graphql.CollectedField, obj *model.AuthResponse) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_AuthResponse_should_show_totp_screen(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.ShouldShowTotpScreen, 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) fieldContext_AuthResponse_should_show_totp_screen(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "AuthResponse",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type Boolean does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _AuthResponse_access_token(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) {
fc, err := ec.fieldContext_AuthResponse_access_token(ctx, field) fc, err := ec.fieldContext_AuthResponse_access_token(ctx, field)
if err != nil { if err != nil {
@ -4031,8 +3931,8 @@ func (ec *executionContext) fieldContext_AuthResponse_user(ctx context.Context,
return fc, nil return fc, nil
} }
func (ec *executionContext) _AuthResponse_totpBase64URL(ctx context.Context, field graphql.CollectedField, obj *model.AuthResponse) (ret graphql.Marshaler) { func (ec *executionContext) _AuthResponse_totp_base64_url(ctx context.Context, field graphql.CollectedField, obj *model.AuthResponse) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_AuthResponse_totpBase64URL(ctx, field) fc, err := ec.fieldContext_AuthResponse_totp_base64_url(ctx, field)
if err != nil { if err != nil {
return graphql.Null return graphql.Null
} }
@ -4045,7 +3945,7 @@ func (ec *executionContext) _AuthResponse_totpBase64URL(ctx context.Context, fie
}() }()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children ctx = rctx // use context from middleware stack in children
return obj.TotpBase64url, nil return obj.TotpBase64URL, nil
}) })
if err != nil { if err != nil {
ec.Error(ctx, err) ec.Error(ctx, err)
@ -4059,7 +3959,7 @@ func (ec *executionContext) _AuthResponse_totpBase64URL(ctx context.Context, fie
return ec.marshalOString2ᚖstring(ctx, field.Selections, res) return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
} }
func (ec *executionContext) fieldContext_AuthResponse_totpBase64URL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { func (ec *executionContext) fieldContext_AuthResponse_totp_base64_url(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{ fc = &graphql.FieldContext{
Object: "AuthResponse", Object: "AuthResponse",
Field: field, Field: field,
@ -4072,8 +3972,8 @@ func (ec *executionContext) fieldContext_AuthResponse_totpBase64URL(ctx context.
return fc, nil return fc, nil
} }
func (ec *executionContext) _AuthResponse_tokenTOTP(ctx context.Context, field graphql.CollectedField, obj *model.AuthResponse) (ret graphql.Marshaler) { func (ec *executionContext) _AuthResponse_totp_token(ctx context.Context, field graphql.CollectedField, obj *model.AuthResponse) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_AuthResponse_tokenTOTP(ctx, field) fc, err := ec.fieldContext_AuthResponse_totp_token(ctx, field)
if err != nil { if err != nil {
return graphql.Null return graphql.Null
} }
@ -4086,7 +3986,7 @@ func (ec *executionContext) _AuthResponse_tokenTOTP(ctx context.Context, field g
}() }()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children ctx = rctx // use context from middleware stack in children
return obj.TokenTotp, nil return obj.TotpToken, nil
}) })
if err != nil { if err != nil {
ec.Error(ctx, err) ec.Error(ctx, err)
@ -4100,7 +4000,7 @@ func (ec *executionContext) _AuthResponse_tokenTOTP(ctx context.Context, field g
return ec.marshalOString2ᚖstring(ctx, field.Selections, res) return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
} }
func (ec *executionContext) fieldContext_AuthResponse_tokenTOTP(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { func (ec *executionContext) fieldContext_AuthResponse_totp_token(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{ fc = &graphql.FieldContext{
Object: "AuthResponse", Object: "AuthResponse",
Field: field, Field: field,
@ -8249,10 +8149,6 @@ func (ec *executionContext) fieldContext_Mutation_signup(ctx context.Context, fi
return ec.fieldContext_AuthResponse_should_show_email_otp_screen(ctx, field) return ec.fieldContext_AuthResponse_should_show_email_otp_screen(ctx, field)
case "should_show_mobile_otp_screen": case "should_show_mobile_otp_screen":
return ec.fieldContext_AuthResponse_should_show_mobile_otp_screen(ctx, field) return ec.fieldContext_AuthResponse_should_show_mobile_otp_screen(ctx, field)
case "should_show_mobile_totp_screen":
return ec.fieldContext_AuthResponse_should_show_mobile_totp_screen(ctx, field)
case "should_show_totp_screen":
return ec.fieldContext_AuthResponse_should_show_totp_screen(ctx, field)
case "access_token": case "access_token":
return ec.fieldContext_AuthResponse_access_token(ctx, field) return ec.fieldContext_AuthResponse_access_token(ctx, field)
case "id_token": case "id_token":
@ -8263,10 +8159,10 @@ func (ec *executionContext) fieldContext_Mutation_signup(ctx context.Context, fi
return ec.fieldContext_AuthResponse_expires_in(ctx, field) return ec.fieldContext_AuthResponse_expires_in(ctx, field)
case "user": case "user":
return ec.fieldContext_AuthResponse_user(ctx, field) return ec.fieldContext_AuthResponse_user(ctx, field)
case "totpBase64URL": case "totp_base64_url":
return ec.fieldContext_AuthResponse_totpBase64URL(ctx, field) return ec.fieldContext_AuthResponse_totp_base64_url(ctx, field)
case "tokenTOTP": case "totp_token":
return ec.fieldContext_AuthResponse_tokenTOTP(ctx, field) return ec.fieldContext_AuthResponse_totp_token(ctx, field)
} }
return nil, fmt.Errorf("no field named %q was found under type AuthResponse", field.Name) return nil, fmt.Errorf("no field named %q was found under type AuthResponse", field.Name)
}, },
@ -8330,10 +8226,6 @@ func (ec *executionContext) fieldContext_Mutation_mobile_signup(ctx context.Cont
return ec.fieldContext_AuthResponse_should_show_email_otp_screen(ctx, field) return ec.fieldContext_AuthResponse_should_show_email_otp_screen(ctx, field)
case "should_show_mobile_otp_screen": case "should_show_mobile_otp_screen":
return ec.fieldContext_AuthResponse_should_show_mobile_otp_screen(ctx, field) return ec.fieldContext_AuthResponse_should_show_mobile_otp_screen(ctx, field)
case "should_show_mobile_totp_screen":
return ec.fieldContext_AuthResponse_should_show_mobile_totp_screen(ctx, field)
case "should_show_totp_screen":
return ec.fieldContext_AuthResponse_should_show_totp_screen(ctx, field)
case "access_token": case "access_token":
return ec.fieldContext_AuthResponse_access_token(ctx, field) return ec.fieldContext_AuthResponse_access_token(ctx, field)
case "id_token": case "id_token":
@ -8344,10 +8236,10 @@ func (ec *executionContext) fieldContext_Mutation_mobile_signup(ctx context.Cont
return ec.fieldContext_AuthResponse_expires_in(ctx, field) return ec.fieldContext_AuthResponse_expires_in(ctx, field)
case "user": case "user":
return ec.fieldContext_AuthResponse_user(ctx, field) return ec.fieldContext_AuthResponse_user(ctx, field)
case "totpBase64URL": case "totp_base64_url":
return ec.fieldContext_AuthResponse_totpBase64URL(ctx, field) return ec.fieldContext_AuthResponse_totp_base64_url(ctx, field)
case "tokenTOTP": case "totp_token":
return ec.fieldContext_AuthResponse_tokenTOTP(ctx, field) return ec.fieldContext_AuthResponse_totp_token(ctx, field)
} }
return nil, fmt.Errorf("no field named %q was found under type AuthResponse", field.Name) return nil, fmt.Errorf("no field named %q was found under type AuthResponse", field.Name)
}, },
@ -8411,10 +8303,6 @@ func (ec *executionContext) fieldContext_Mutation_login(ctx context.Context, fie
return ec.fieldContext_AuthResponse_should_show_email_otp_screen(ctx, field) return ec.fieldContext_AuthResponse_should_show_email_otp_screen(ctx, field)
case "should_show_mobile_otp_screen": case "should_show_mobile_otp_screen":
return ec.fieldContext_AuthResponse_should_show_mobile_otp_screen(ctx, field) return ec.fieldContext_AuthResponse_should_show_mobile_otp_screen(ctx, field)
case "should_show_mobile_totp_screen":
return ec.fieldContext_AuthResponse_should_show_mobile_totp_screen(ctx, field)
case "should_show_totp_screen":
return ec.fieldContext_AuthResponse_should_show_totp_screen(ctx, field)
case "access_token": case "access_token":
return ec.fieldContext_AuthResponse_access_token(ctx, field) return ec.fieldContext_AuthResponse_access_token(ctx, field)
case "id_token": case "id_token":
@ -8425,10 +8313,10 @@ func (ec *executionContext) fieldContext_Mutation_login(ctx context.Context, fie
return ec.fieldContext_AuthResponse_expires_in(ctx, field) return ec.fieldContext_AuthResponse_expires_in(ctx, field)
case "user": case "user":
return ec.fieldContext_AuthResponse_user(ctx, field) return ec.fieldContext_AuthResponse_user(ctx, field)
case "totpBase64URL": case "totp_base64_url":
return ec.fieldContext_AuthResponse_totpBase64URL(ctx, field) return ec.fieldContext_AuthResponse_totp_base64_url(ctx, field)
case "tokenTOTP": case "totp_token":
return ec.fieldContext_AuthResponse_tokenTOTP(ctx, field) return ec.fieldContext_AuthResponse_totp_token(ctx, field)
} }
return nil, fmt.Errorf("no field named %q was found under type AuthResponse", field.Name) return nil, fmt.Errorf("no field named %q was found under type AuthResponse", field.Name)
}, },
@ -8492,10 +8380,6 @@ func (ec *executionContext) fieldContext_Mutation_mobile_login(ctx context.Conte
return ec.fieldContext_AuthResponse_should_show_email_otp_screen(ctx, field) return ec.fieldContext_AuthResponse_should_show_email_otp_screen(ctx, field)
case "should_show_mobile_otp_screen": case "should_show_mobile_otp_screen":
return ec.fieldContext_AuthResponse_should_show_mobile_otp_screen(ctx, field) return ec.fieldContext_AuthResponse_should_show_mobile_otp_screen(ctx, field)
case "should_show_mobile_totp_screen":
return ec.fieldContext_AuthResponse_should_show_mobile_totp_screen(ctx, field)
case "should_show_totp_screen":
return ec.fieldContext_AuthResponse_should_show_totp_screen(ctx, field)
case "access_token": case "access_token":
return ec.fieldContext_AuthResponse_access_token(ctx, field) return ec.fieldContext_AuthResponse_access_token(ctx, field)
case "id_token": case "id_token":
@ -8506,10 +8390,10 @@ func (ec *executionContext) fieldContext_Mutation_mobile_login(ctx context.Conte
return ec.fieldContext_AuthResponse_expires_in(ctx, field) return ec.fieldContext_AuthResponse_expires_in(ctx, field)
case "user": case "user":
return ec.fieldContext_AuthResponse_user(ctx, field) return ec.fieldContext_AuthResponse_user(ctx, field)
case "totpBase64URL": case "totp_base64_url":
return ec.fieldContext_AuthResponse_totpBase64URL(ctx, field) return ec.fieldContext_AuthResponse_totp_base64_url(ctx, field)
case "tokenTOTP": case "totp_token":
return ec.fieldContext_AuthResponse_tokenTOTP(ctx, field) return ec.fieldContext_AuthResponse_totp_token(ctx, field)
} }
return nil, fmt.Errorf("no field named %q was found under type AuthResponse", field.Name) return nil, fmt.Errorf("no field named %q was found under type AuthResponse", field.Name)
}, },
@ -8739,10 +8623,6 @@ func (ec *executionContext) fieldContext_Mutation_verify_email(ctx context.Conte
return ec.fieldContext_AuthResponse_should_show_email_otp_screen(ctx, field) return ec.fieldContext_AuthResponse_should_show_email_otp_screen(ctx, field)
case "should_show_mobile_otp_screen": case "should_show_mobile_otp_screen":
return ec.fieldContext_AuthResponse_should_show_mobile_otp_screen(ctx, field) return ec.fieldContext_AuthResponse_should_show_mobile_otp_screen(ctx, field)
case "should_show_mobile_totp_screen":
return ec.fieldContext_AuthResponse_should_show_mobile_totp_screen(ctx, field)
case "should_show_totp_screen":
return ec.fieldContext_AuthResponse_should_show_totp_screen(ctx, field)
case "access_token": case "access_token":
return ec.fieldContext_AuthResponse_access_token(ctx, field) return ec.fieldContext_AuthResponse_access_token(ctx, field)
case "id_token": case "id_token":
@ -8753,10 +8633,10 @@ func (ec *executionContext) fieldContext_Mutation_verify_email(ctx context.Conte
return ec.fieldContext_AuthResponse_expires_in(ctx, field) return ec.fieldContext_AuthResponse_expires_in(ctx, field)
case "user": case "user":
return ec.fieldContext_AuthResponse_user(ctx, field) return ec.fieldContext_AuthResponse_user(ctx, field)
case "totpBase64URL": case "totp_base64_url":
return ec.fieldContext_AuthResponse_totpBase64URL(ctx, field) return ec.fieldContext_AuthResponse_totp_base64_url(ctx, field)
case "tokenTOTP": case "totp_token":
return ec.fieldContext_AuthResponse_tokenTOTP(ctx, field) return ec.fieldContext_AuthResponse_totp_token(ctx, field)
} }
return nil, fmt.Errorf("no field named %q was found under type AuthResponse", field.Name) return nil, fmt.Errorf("no field named %q was found under type AuthResponse", field.Name)
}, },
@ -9056,10 +8936,6 @@ func (ec *executionContext) fieldContext_Mutation_verify_otp(ctx context.Context
return ec.fieldContext_AuthResponse_should_show_email_otp_screen(ctx, field) return ec.fieldContext_AuthResponse_should_show_email_otp_screen(ctx, field)
case "should_show_mobile_otp_screen": case "should_show_mobile_otp_screen":
return ec.fieldContext_AuthResponse_should_show_mobile_otp_screen(ctx, field) return ec.fieldContext_AuthResponse_should_show_mobile_otp_screen(ctx, field)
case "should_show_mobile_totp_screen":
return ec.fieldContext_AuthResponse_should_show_mobile_totp_screen(ctx, field)
case "should_show_totp_screen":
return ec.fieldContext_AuthResponse_should_show_totp_screen(ctx, field)
case "access_token": case "access_token":
return ec.fieldContext_AuthResponse_access_token(ctx, field) return ec.fieldContext_AuthResponse_access_token(ctx, field)
case "id_token": case "id_token":
@ -9070,10 +8946,10 @@ func (ec *executionContext) fieldContext_Mutation_verify_otp(ctx context.Context
return ec.fieldContext_AuthResponse_expires_in(ctx, field) return ec.fieldContext_AuthResponse_expires_in(ctx, field)
case "user": case "user":
return ec.fieldContext_AuthResponse_user(ctx, field) return ec.fieldContext_AuthResponse_user(ctx, field)
case "totpBase64URL": case "totp_base64_url":
return ec.fieldContext_AuthResponse_totpBase64URL(ctx, field) return ec.fieldContext_AuthResponse_totp_base64_url(ctx, field)
case "tokenTOTP": case "totp_token":
return ec.fieldContext_AuthResponse_tokenTOTP(ctx, field) return ec.fieldContext_AuthResponse_totp_token(ctx, field)
} }
return nil, fmt.Errorf("no field named %q was found under type AuthResponse", field.Name) return nil, fmt.Errorf("no field named %q was found under type AuthResponse", field.Name)
}, },
@ -9196,10 +9072,6 @@ func (ec *executionContext) fieldContext_Mutation_verify_totp(ctx context.Contex
return ec.fieldContext_AuthResponse_should_show_email_otp_screen(ctx, field) return ec.fieldContext_AuthResponse_should_show_email_otp_screen(ctx, field)
case "should_show_mobile_otp_screen": case "should_show_mobile_otp_screen":
return ec.fieldContext_AuthResponse_should_show_mobile_otp_screen(ctx, field) return ec.fieldContext_AuthResponse_should_show_mobile_otp_screen(ctx, field)
case "should_show_mobile_totp_screen":
return ec.fieldContext_AuthResponse_should_show_mobile_totp_screen(ctx, field)
case "should_show_totp_screen":
return ec.fieldContext_AuthResponse_should_show_totp_screen(ctx, field)
case "access_token": case "access_token":
return ec.fieldContext_AuthResponse_access_token(ctx, field) return ec.fieldContext_AuthResponse_access_token(ctx, field)
case "id_token": case "id_token":
@ -9210,10 +9082,10 @@ func (ec *executionContext) fieldContext_Mutation_verify_totp(ctx context.Contex
return ec.fieldContext_AuthResponse_expires_in(ctx, field) return ec.fieldContext_AuthResponse_expires_in(ctx, field)
case "user": case "user":
return ec.fieldContext_AuthResponse_user(ctx, field) return ec.fieldContext_AuthResponse_user(ctx, field)
case "totpBase64URL": case "totp_base64_url":
return ec.fieldContext_AuthResponse_totpBase64URL(ctx, field) return ec.fieldContext_AuthResponse_totp_base64_url(ctx, field)
case "tokenTOTP": case "totp_token":
return ec.fieldContext_AuthResponse_tokenTOTP(ctx, field) return ec.fieldContext_AuthResponse_totp_token(ctx, field)
} }
return nil, fmt.Errorf("no field named %q was found under type AuthResponse", field.Name) return nil, fmt.Errorf("no field named %q was found under type AuthResponse", field.Name)
}, },
@ -10569,10 +10441,6 @@ func (ec *executionContext) fieldContext_Query_session(ctx context.Context, fiel
return ec.fieldContext_AuthResponse_should_show_email_otp_screen(ctx, field) return ec.fieldContext_AuthResponse_should_show_email_otp_screen(ctx, field)
case "should_show_mobile_otp_screen": case "should_show_mobile_otp_screen":
return ec.fieldContext_AuthResponse_should_show_mobile_otp_screen(ctx, field) return ec.fieldContext_AuthResponse_should_show_mobile_otp_screen(ctx, field)
case "should_show_mobile_totp_screen":
return ec.fieldContext_AuthResponse_should_show_mobile_totp_screen(ctx, field)
case "should_show_totp_screen":
return ec.fieldContext_AuthResponse_should_show_totp_screen(ctx, field)
case "access_token": case "access_token":
return ec.fieldContext_AuthResponse_access_token(ctx, field) return ec.fieldContext_AuthResponse_access_token(ctx, field)
case "id_token": case "id_token":
@ -10583,10 +10451,10 @@ func (ec *executionContext) fieldContext_Query_session(ctx context.Context, fiel
return ec.fieldContext_AuthResponse_expires_in(ctx, field) return ec.fieldContext_AuthResponse_expires_in(ctx, field)
case "user": case "user":
return ec.fieldContext_AuthResponse_user(ctx, field) return ec.fieldContext_AuthResponse_user(ctx, field)
case "totpBase64URL": case "totp_base64_url":
return ec.fieldContext_AuthResponse_totpBase64URL(ctx, field) return ec.fieldContext_AuthResponse_totp_base64_url(ctx, field)
case "tokenTOTP": case "totp_token":
return ec.fieldContext_AuthResponse_tokenTOTP(ctx, field) return ec.fieldContext_AuthResponse_totp_token(ctx, field)
} }
return nil, fmt.Errorf("no field named %q was found under type AuthResponse", field.Name) return nil, fmt.Errorf("no field named %q was found under type AuthResponse", field.Name)
}, },
@ -18740,14 +18608,6 @@ func (ec *executionContext) _AuthResponse(ctx context.Context, sel ast.Selection
out.Values[i] = ec._AuthResponse_should_show_mobile_otp_screen(ctx, field, obj) out.Values[i] = ec._AuthResponse_should_show_mobile_otp_screen(ctx, field, obj)
case "should_show_mobile_totp_screen":
out.Values[i] = ec._AuthResponse_should_show_mobile_totp_screen(ctx, field, obj)
case "should_show_totp_screen":
out.Values[i] = ec._AuthResponse_should_show_totp_screen(ctx, field, obj)
case "access_token": case "access_token":
out.Values[i] = ec._AuthResponse_access_token(ctx, field, obj) out.Values[i] = ec._AuthResponse_access_token(ctx, field, obj)
@ -18768,13 +18628,13 @@ func (ec *executionContext) _AuthResponse(ctx context.Context, sel ast.Selection
out.Values[i] = ec._AuthResponse_user(ctx, field, obj) out.Values[i] = ec._AuthResponse_user(ctx, field, obj)
case "totpBase64URL": case "totp_base64_url":
out.Values[i] = ec._AuthResponse_totpBase64URL(ctx, field, obj) out.Values[i] = ec._AuthResponse_totp_base64_url(ctx, field, obj)
case "tokenTOTP": case "totp_token":
out.Values[i] = ec._AuthResponse_tokenTOTP(ctx, field, obj) out.Values[i] = ec._AuthResponse_totp_token(ctx, field, obj)
default: default:
panic("unknown field " + strconv.Quote(field.Name)) panic("unknown field " + strconv.Quote(field.Name))

View File

@ -26,18 +26,16 @@ type AdminSignupInput struct {
} }
type AuthResponse struct { type AuthResponse struct {
Message string `json:"message"` Message string `json:"message"`
ShouldShowEmailOtpScreen *bool `json:"should_show_email_otp_screen"` ShouldShowEmailOtpScreen *bool `json:"should_show_email_otp_screen"`
ShouldShowMobileOtpScreen *bool `json:"should_show_mobile_otp_screen"` ShouldShowMobileOtpScreen *bool `json:"should_show_mobile_otp_screen"`
ShouldShowMobileTotpScreen *bool `json:"should_show_mobile_totp_screen"` AccessToken *string `json:"access_token"`
ShouldShowTotpScreen *bool `json:"should_show_totp_screen"` IDToken *string `json:"id_token"`
AccessToken *string `json:"access_token"` RefreshToken *string `json:"refresh_token"`
IDToken *string `json:"id_token"` ExpiresIn *int64 `json:"expires_in"`
RefreshToken *string `json:"refresh_token"` User *User `json:"user"`
ExpiresIn *int64 `json:"expires_in"` TotpBase64URL *string `json:"totp_base64_url"`
User *User `json:"user"` TotpToken *string `json:"totp_token"`
TotpBase64url *string `json:"totpBase64URL"`
TokenTotp *string `json:"tokenTOTP"`
} }
type DeleteEmailTemplateRequest struct { type DeleteEmailTemplateRequest struct {

View File

@ -95,15 +95,13 @@ type AuthResponse {
message: String! message: String!
should_show_email_otp_screen: Boolean should_show_email_otp_screen: Boolean
should_show_mobile_otp_screen: Boolean should_show_mobile_otp_screen: Boolean
should_show_mobile_totp_screen: Boolean
should_show_totp_screen: Boolean
access_token: String access_token: String
id_token: String id_token: String
refresh_token: String refresh_token: String
expires_in: Int64 expires_in: Int64
user: User user: User
totpBase64URL: String totp_base64_url: String
tokenTOTP: String totp_token: String
} }
type Response { type Response {

View File

@ -3,16 +3,17 @@ package resolvers
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/authorizerdev/authorizer/server/crypto"
"strings" "strings"
"time" "time"
"github.com/google/uuid" "github.com/google/uuid"
log "github.com/sirupsen/logrus"
"golang.org/x/crypto/bcrypt" "golang.org/x/crypto/bcrypt"
log "github.com/sirupsen/logrus"
"github.com/authorizerdev/authorizer/server/constants" "github.com/authorizerdev/authorizer/server/constants"
"github.com/authorizerdev/authorizer/server/cookie" "github.com/authorizerdev/authorizer/server/cookie"
"github.com/authorizerdev/authorizer/server/crypto"
"github.com/authorizerdev/authorizer/server/db" "github.com/authorizerdev/authorizer/server/db"
"github.com/authorizerdev/authorizer/server/db/models" "github.com/authorizerdev/authorizer/server/db/models"
"github.com/authorizerdev/authorizer/server/email" "github.com/authorizerdev/authorizer/server/email"
@ -161,6 +162,7 @@ func LoginResolver(ctx context.Context, params model.LoginInput) (*model.AuthRes
}, nil }, nil
} }
// if mfa enabled and also totp enabled
if !isMFADisabled && refs.BoolValue(user.IsMultiFactorAuthEnabled) && !isTOTPLoginDisabled { if !isMFADisabled && refs.BoolValue(user.IsMultiFactorAuthEnabled) && !isTOTPLoginDisabled {
pubKey, err := memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeyJwtPublicKey) pubKey, err := memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeyJwtPublicKey)
if err != nil { if err != nil {
@ -172,26 +174,30 @@ func LoginResolver(ctx context.Context, params model.LoginInput) (*model.AuthRes
log.Debug("error while parsing public key") log.Debug("error while parsing public key")
} }
//encrypting user id, so it can be used as token for verifying
encryptedUserId, err := crypto.EncryptRSA(user.ID, *publicKey) encryptedUserId, err := crypto.EncryptRSA(user.ID, *publicKey)
if err != nil { if err != nil {
log.Debug("error while encrypting user id") log.Debug("error while encrypting user id")
} }
// for first time user or whose totp is not verified
if !user.TotpVerified { if !user.TotpVerified {
base64URL, err := db.Provider.GenerateTotp(ctx, user.ID) base64URL, err := db.Provider.GenerateTotp(ctx, user.ID)
if err != nil { if err != nil {
log.Debug("error while generating base64 url: ", err) log.Debug("error while generating base64 url: ", err)
} }
// when user is first time registering for totp
res = &model.AuthResponse{ res = &model.AuthResponse{
Message: `Proceed to totp screen`, Message: `Proceed to totp screen`,
TotpBase64url: base64URL, TotpBase64URL: base64URL,
TokenTotp: &encryptedUserId, TotpToken: &encryptedUserId,
} }
return res, nil return res, nil
} else { } else {
//when user is already register for totp
res = &model.AuthResponse{ res = &model.AuthResponse{
Message: `Proceed to totp screen`, Message: `Proceed to totp screen`,
TokenTotp: &encryptedUserId, TotpToken: &encryptedUserId,
} }
return res, nil return res, nil
} }

View File

@ -3,15 +3,16 @@ package resolvers
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/authorizerdev/authorizer/server/crypto"
"strings" "strings"
"time" "time"
"github.com/google/uuid" "github.com/google/uuid"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/authorizerdev/authorizer/server/constants" "github.com/authorizerdev/authorizer/server/constants"
"github.com/authorizerdev/authorizer/server/cookie" "github.com/authorizerdev/authorizer/server/cookie"
"github.com/authorizerdev/authorizer/server/crypto"
"github.com/authorizerdev/authorizer/server/db" "github.com/authorizerdev/authorizer/server/db"
"github.com/authorizerdev/authorizer/server/db/models" "github.com/authorizerdev/authorizer/server/db/models"
"github.com/authorizerdev/authorizer/server/graph/model" "github.com/authorizerdev/authorizer/server/graph/model"
@ -55,7 +56,7 @@ func VerifyTotpResolver(ctx context.Context, params model.VerifyTOTPRequest) (*m
status, err := db.Provider.ValidatePasscode(ctx, params.Otp, userID) status, err := db.Provider.ValidatePasscode(ctx, params.Otp, userID)
if err != nil || !status { if err != nil || !status {
return nil, fmt.Errorf("error while validating passcode", err) return nil, fmt.Errorf("error while validating passcode")
} }
code := "" code := ""

View File

@ -28,8 +28,6 @@ func revokeAccessTest(t *testing.T, s TestSetup) {
verifyRes, err := resolvers.VerifyEmailResolver(ctx, model.VerifyEmailInput{ verifyRes, err := resolvers.VerifyEmailResolver(ctx, model.VerifyEmailInput{
Token: verificationRequest.Token, Token: verificationRequest.Token,
}) })
fmt.Println("\n", verifyRes)
fmt.Println("\n", err)
assert.NoError(t, err) assert.NoError(t, err)
assert.NotNil(t, verifyRes.AccessToken) assert.NotNil(t, verifyRes.AccessToken)

View File

@ -23,8 +23,6 @@ func verificationRequestsTest(t *testing.T, s TestSetup) {
Password: s.TestInfo.Password, Password: s.TestInfo.Password,
ConfirmPassword: s.TestInfo.Password, ConfirmPassword: s.TestInfo.Password,
}) })
fmt.Println("res", res)
fmt.Println("err", err)
assert.NoError(t, err) assert.NoError(t, err)
assert.NotNil(t, res) assert.NotNil(t, res)
limit := int64(10) limit := int64(10)

View File

@ -5,6 +5,13 @@ import (
"context" "context"
"encoding/base64" "encoding/base64"
"fmt" "fmt"
"strings"
"testing"
"github.com/gokyle/twofactor"
"github.com/stretchr/testify/assert"
"github.com/tuotoo/qrcode"
"github.com/authorizerdev/authorizer/server/constants" "github.com/authorizerdev/authorizer/server/constants"
"github.com/authorizerdev/authorizer/server/db" "github.com/authorizerdev/authorizer/server/db"
"github.com/authorizerdev/authorizer/server/graph/model" "github.com/authorizerdev/authorizer/server/graph/model"
@ -12,11 +19,6 @@ import (
"github.com/authorizerdev/authorizer/server/refs" "github.com/authorizerdev/authorizer/server/refs"
"github.com/authorizerdev/authorizer/server/resolvers" "github.com/authorizerdev/authorizer/server/resolvers"
"github.com/authorizerdev/authorizer/server/token" "github.com/authorizerdev/authorizer/server/token"
"github.com/gokyle/twofactor"
"github.com/stretchr/testify/assert"
"github.com/tuotoo/qrcode"
"strings"
"testing"
) )
func verifyTOTPTest(t *testing.T, s TestSetup) { func verifyTOTPTest(t *testing.T, s TestSetup) {
@ -67,13 +69,13 @@ func verifyTOTPTest(t *testing.T, s TestSetup) {
}) })
assert.NoError(t, err) assert.NoError(t, err)
assert.NotNil(t, loginRes) assert.NotNil(t, loginRes)
assert.NotNil(t, loginRes.TotpBase64url) assert.NotNil(t, loginRes.TotpBase64URL)
assert.NotNil(t, loginRes.TokenTotp) assert.NotNil(t, loginRes.TotpToken)
assert.Nil(t, loginRes.AccessToken) assert.Nil(t, loginRes.AccessToken)
assert.Equal(t, loginRes.Message, `Proceed to totp screen`) assert.Equal(t, loginRes.Message, `Proceed to totp screen`)
// get totp url for validation // get totp url for validation
pngBytes, err := base64.StdEncoding.DecodeString(*loginRes.TotpBase64url) pngBytes, err := base64.StdEncoding.DecodeString(*loginRes.TotpBase64URL)
assert.NoError(t, err) assert.NoError(t, err)
qrmatrix, err := qrcode.Decode(bytes.NewReader(pngBytes)) qrmatrix, err := qrcode.Decode(bytes.NewReader(pngBytes))
assert.NoError(t, err) assert.NoError(t, err)
@ -89,7 +91,7 @@ func verifyTOTPTest(t *testing.T, s TestSetup) {
valid, err := resolvers.VerifyTotpResolver(ctx, model.VerifyTOTPRequest{ valid, err := resolvers.VerifyTotpResolver(ctx, model.VerifyTOTPRequest{
Otp: code, Otp: code,
Token: *loginRes.TokenTotp, Token: *loginRes.TotpToken,
}) })
accessToken := *valid.AccessToken accessToken := *valid.AccessToken
@ -126,8 +128,8 @@ func verifyTOTPTest(t *testing.T, s TestSetup) {
}) })
assert.NoError(t, err) assert.NoError(t, err)
assert.NotNil(t, loginRes) assert.NotNil(t, loginRes)
assert.NotNil(t, loginRes.TokenTotp) assert.NotNil(t, loginRes.TotpToken)
assert.Nil(t, loginRes.TotpBase64url) assert.Nil(t, loginRes.TotpBase64URL)
assert.Nil(t, loginRes.AccessToken) assert.Nil(t, loginRes.AccessToken)
assert.Equal(t, loginRes.Message, `Proceed to totp screen`) assert.Equal(t, loginRes.Message, `Proceed to totp screen`)
@ -136,7 +138,7 @@ func verifyTOTPTest(t *testing.T, s TestSetup) {
valid, err = resolvers.VerifyTotpResolver(ctx, model.VerifyTOTPRequest{ valid, err = resolvers.VerifyTotpResolver(ctx, model.VerifyTOTPRequest{
Otp: code, Otp: code,
Token: *loginRes.TokenTotp, Token: *loginRes.TotpToken,
}) })
assert.NoError(t, err) assert.NoError(t, err)
assert.NotNil(t, *valid.AccessToken) assert.NotNil(t, *valid.AccessToken)