step 2 : auth dengan encrpty not fixed

This commit is contained in:
sindhu
2024-01-18 08:29:34 +07:00
parent a2defaaaa8
commit 2bd8da63fc
8 changed files with 235 additions and 162 deletions

View File

@@ -48,8 +48,7 @@ type DirectiveRoot struct {
type ComplexityRoot struct {
Mutation struct {
CreateTodo func(childComplexity int, input model.NewTodo) int
GenerateToken func(childComplexity int, email string, idGoogleSignIn string) int
LoginAttendance func(childComplexity int, email string, idGoogleSignIn string) int
LoginAttendance func(childComplexity int, email string, idGoogleSignIn string, publickey string) int
}
Query struct {
@@ -94,8 +93,7 @@ type ComplexityRoot struct {
type MutationResolver interface {
CreateTodo(ctx context.Context, input model.NewTodo) (*model.Todo, error)
GenerateToken(ctx context.Context, email string, idGoogleSignIn string) (*model.TokenResponse, error)
LoginAttendance(ctx context.Context, email string, idGoogleSignIn string) (*model.Staff, error)
LoginAttendance(ctx context.Context, email string, idGoogleSignIn string, publickey string) (*model.Staff, error)
}
type QueryResolver interface {
Todos(ctx context.Context) ([]*model.Todo, error)
@@ -135,18 +133,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Mutation.CreateTodo(childComplexity, args["input"].(model.NewTodo)), true
case "Mutation.generateToken":
if e.complexity.Mutation.GenerateToken == nil {
break
}
args, err := ec.field_Mutation_generateToken_args(context.TODO(), rawArgs)
if err != nil {
return 0, false
}
return e.complexity.Mutation.GenerateToken(childComplexity, args["email"].(string), args["id_google_sign_in"].(string)), true
case "Mutation.loginAttendance":
if e.complexity.Mutation.LoginAttendance == nil {
break
@@ -157,7 +143,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return 0, false
}
return e.complexity.Mutation.LoginAttendance(childComplexity, args["email"].(string), args["id_google_sign_in"].(string)), true
return e.complexity.Mutation.LoginAttendance(childComplexity, args["email"].(string), args["id_google_sign_in"].(string), args["publickey"].(string)), true
case "Query.searchStaffByEmail":
if e.complexity.Query.SearchStaffByEmail == nil {
@@ -508,8 +494,7 @@ extend type Query {
# mutation untuk perubahan data
extend type Mutation {
generateToken(email: String!, id_google_sign_in:String!): TokenResponse!
loginAttendance(email:String!, id_google_sign_in:String!) : Staff!
loginAttendance(email:String!, id_google_sign_in:String!, publickey:String!) : Staff!
}`, BuiltIn: false},
}
var parsedSchema = gqlparser.MustLoadSchema(sources...)
@@ -533,30 +518,6 @@ func (ec *executionContext) field_Mutation_createTodo_args(ctx context.Context,
return args, nil
}
func (ec *executionContext) field_Mutation_generateToken_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
var arg0 string
if tmp, ok := rawArgs["email"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("email"))
arg0, err = ec.unmarshalNString2string(ctx, tmp)
if err != nil {
return nil, err
}
}
args["email"] = arg0
var arg1 string
if tmp, ok := rawArgs["id_google_sign_in"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id_google_sign_in"))
arg1, err = ec.unmarshalNString2string(ctx, tmp)
if err != nil {
return nil, err
}
}
args["id_google_sign_in"] = arg1
return args, nil
}
func (ec *executionContext) field_Mutation_loginAttendance_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
@@ -578,6 +539,15 @@ func (ec *executionContext) field_Mutation_loginAttendance_args(ctx context.Cont
}
}
args["id_google_sign_in"] = arg1
var arg2 string
if tmp, ok := rawArgs["publickey"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("publickey"))
arg2, err = ec.unmarshalNString2string(ctx, tmp)
if err != nil {
return nil, err
}
}
args["publickey"] = arg2
return args, nil
}
@@ -762,67 +732,6 @@ func (ec *executionContext) fieldContext_Mutation_createTodo(ctx context.Context
return fc, nil
}
func (ec *executionContext) _Mutation_generateToken(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Mutation_generateToken(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 ec.resolvers.Mutation().GenerateToken(rctx, fc.Args["email"].(string), fc.Args["id_google_sign_in"].(string))
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !graphql.HasFieldError(ctx, fc) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.(*model.TokenResponse)
fc.Result = res
return ec.marshalNTokenResponse2ᚖcomᚗsismedikaᚗcomᚗabsensiᚋgraphᚋmodelᚐTokenResponse(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_Mutation_generateToken(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "Mutation",
Field: field,
IsMethod: true,
IsResolver: true,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
switch field.Name {
case "token":
return ec.fieldContext_TokenResponse_token(ctx, field)
case "message":
return ec.fieldContext_TokenResponse_message(ctx, field)
}
return nil, fmt.Errorf("no field named %q was found under type TokenResponse", field.Name)
},
}
defer func() {
if r := recover(); r != nil {
err = ec.Recover(ctx, r)
ec.Error(ctx, err)
}
}()
ctx = graphql.WithFieldContext(ctx, fc)
if fc.Args, err = ec.field_Mutation_generateToken_args(ctx, field.ArgumentMap(ec.Variables)); err != nil {
ec.Error(ctx, err)
return fc, err
}
return fc, nil
}
func (ec *executionContext) _Mutation_loginAttendance(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_Mutation_loginAttendance(ctx, field)
if err != nil {
@@ -837,7 +746,7 @@ func (ec *executionContext) _Mutation_loginAttendance(ctx context.Context, field
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return ec.resolvers.Mutation().LoginAttendance(rctx, fc.Args["email"].(string), fc.Args["id_google_sign_in"].(string))
return ec.resolvers.Mutation().LoginAttendance(rctx, fc.Args["email"].(string), fc.Args["id_google_sign_in"].(string), fc.Args["publickey"].(string))
})
if err != nil {
ec.Error(ctx, err)
@@ -4030,13 +3939,6 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet)
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "generateToken":
out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
return ec._Mutation_generateToken(ctx, field)
})
if out.Values[i] == graphql.Null {
out.Invalids++
}
case "loginAttendance":
out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) {
return ec._Mutation_loginAttendance(ctx, field)
@@ -4906,20 +4808,6 @@ func (ec *executionContext) marshalNTodo2ᚖcomᚗsismedikaᚗcomᚗabsensiᚋgr
return ec._Todo(ctx, sel, v)
}
func (ec *executionContext) marshalNTokenResponse2comᚗsismedikaᚗcomᚗabsensiᚋgraphᚋmodelᚐTokenResponse(ctx context.Context, sel ast.SelectionSet, v model.TokenResponse) graphql.Marshaler {
return ec._TokenResponse(ctx, sel, &v)
}
func (ec *executionContext) marshalNTokenResponse2ᚖcomᚗsismedikaᚗcomᚗabsensiᚋgraphᚋmodelᚐTokenResponse(ctx context.Context, sel ast.SelectionSet, v *model.TokenResponse) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "the requested element is null which the schema does not allow")
}
return graphql.Null
}
return ec._TokenResponse(ctx, sel, v)
}
func (ec *executionContext) marshalNUser2ᚖcomᚗsismedikaᚗcomᚗabsensiᚋgraphᚋmodelᚐUser(ctx context.Context, sel ast.SelectionSet, v *model.User) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {