Remove access_token from response
This commit is contained in:
parent
047e867faa
commit
266b9e34b6
|
@ -18,11 +18,10 @@ func adminLoginTests(s TestSetup, t *testing.T) {
|
||||||
|
|
||||||
assert.NotNil(t, err)
|
assert.NotNil(t, err)
|
||||||
|
|
||||||
res, err := resolvers.AdminLoginResolver(ctx, model.AdminLoginInput{
|
_, err = resolvers.AdminLoginResolver(ctx, model.AdminLoginInput{
|
||||||
AdminSecret: constants.EnvData.ADMIN_SECRET,
|
AdminSecret: constants.EnvData.ADMIN_SECRET,
|
||||||
})
|
})
|
||||||
|
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Greater(t, len(res.AccessToken), 0)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,8 @@ func adminSessionTests(s TestSetup, t *testing.T) {
|
||||||
h, err := utils.HashPassword(constants.EnvData.ADMIN_SECRET)
|
h, err := utils.HashPassword(constants.EnvData.ADMIN_SECRET)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
req.Header.Set("Cookie", fmt.Sprintf("%s=%s", constants.EnvData.ADMIN_COOKIE_NAME, h))
|
req.Header.Set("Cookie", fmt.Sprintf("%s=%s", constants.EnvData.ADMIN_COOKIE_NAME, h))
|
||||||
res, err := resolvers.AdminSession(ctx)
|
_, err = resolvers.AdminSession(ctx)
|
||||||
|
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Greater(t, len(res.AccessToken), 0)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,11 +22,10 @@ func adminSignupTests(s TestSetup, t *testing.T) {
|
||||||
// reset env for test to pass
|
// reset env for test to pass
|
||||||
constants.EnvData.ADMIN_SECRET = ""
|
constants.EnvData.ADMIN_SECRET = ""
|
||||||
|
|
||||||
res, err := resolvers.AdminSignupResolver(ctx, model.AdminLoginInput{
|
_, err = resolvers.AdminSignupResolver(ctx, model.AdminLoginInput{
|
||||||
AdminSecret: uuid.New().String(),
|
AdminSecret: uuid.New().String(),
|
||||||
})
|
})
|
||||||
|
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Greater(t, len(res.AccessToken), 0)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,7 @@ type DirectiveRoot struct {
|
||||||
|
|
||||||
type ComplexityRoot struct {
|
type ComplexityRoot struct {
|
||||||
AdminLoginResponse struct {
|
AdminLoginResponse struct {
|
||||||
AccessToken func(childComplexity int) int
|
Message func(childComplexity int) int
|
||||||
Message func(childComplexity int) int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthResponse struct {
|
AuthResponse struct {
|
||||||
|
@ -211,13 +210,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
||||||
_ = ec
|
_ = ec
|
||||||
switch typeName + "." + field {
|
switch typeName + "." + field {
|
||||||
|
|
||||||
case "AdminLoginResponse.access_token":
|
|
||||||
if e.complexity.AdminLoginResponse.AccessToken == nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
return e.complexity.AdminLoginResponse.AccessToken(childComplexity), true
|
|
||||||
|
|
||||||
case "AdminLoginResponse.message":
|
case "AdminLoginResponse.message":
|
||||||
if e.complexity.AdminLoginResponse.Message == nil {
|
if e.complexity.AdminLoginResponse.Message == nil {
|
||||||
break
|
break
|
||||||
|
@ -1076,7 +1068,6 @@ type Response {
|
||||||
|
|
||||||
type AdminLoginResponse {
|
type AdminLoginResponse {
|
||||||
message: String!
|
message: String!
|
||||||
access_token: String!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config {
|
type Config {
|
||||||
|
@ -1567,41 +1558,6 @@ func (ec *executionContext) _AdminLoginResponse_message(ctx context.Context, fie
|
||||||
return ec.marshalNString2string(ctx, field.Selections, res)
|
return ec.marshalNString2string(ctx, field.Selections, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) _AdminLoginResponse_access_token(ctx context.Context, field graphql.CollectedField, obj *model.AdminLoginResponse) (ret graphql.Marshaler) {
|
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil {
|
|
||||||
ec.Error(ctx, ec.Recover(ctx, r))
|
|
||||||
ret = graphql.Null
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
fc := &graphql.FieldContext{
|
|
||||||
Object: "AdminLoginResponse",
|
|
||||||
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.AccessToken, nil
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
ec.Error(ctx, err)
|
|
||||||
return graphql.Null
|
|
||||||
}
|
|
||||||
if resTmp == nil {
|
|
||||||
if !graphql.HasFieldError(ctx, fc) {
|
|
||||||
ec.Errorf(ctx, "must not be null")
|
|
||||||
}
|
|
||||||
return graphql.Null
|
|
||||||
}
|
|
||||||
res := resTmp.(string)
|
|
||||||
fc.Result = res
|
|
||||||
return ec.marshalNString2string(ctx, field.Selections, res)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ec *executionContext) _AuthResponse_message(ctx context.Context, field graphql.CollectedField, obj *model.AuthResponse) (ret graphql.Marshaler) {
|
func (ec *executionContext) _AuthResponse_message(ctx context.Context, field graphql.CollectedField, obj *model.AuthResponse) (ret graphql.Marshaler) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
|
@ -6838,11 +6794,6 @@ func (ec *executionContext) _AdminLoginResponse(ctx context.Context, sel ast.Sel
|
||||||
if out.Values[i] == graphql.Null {
|
if out.Values[i] == graphql.Null {
|
||||||
invalids++
|
invalids++
|
||||||
}
|
}
|
||||||
case "access_token":
|
|
||||||
out.Values[i] = ec._AdminLoginResponse_access_token(ctx, field, obj)
|
|
||||||
if out.Values[i] == graphql.Null {
|
|
||||||
invalids++
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
panic("unknown field " + strconv.Quote(field.Name))
|
panic("unknown field " + strconv.Quote(field.Name))
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,7 @@ type AdminLoginInput struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type AdminLoginResponse struct {
|
type AdminLoginResponse struct {
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
AccessToken string `json:"access_token"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthResponse struct {
|
type AuthResponse struct {
|
||||||
|
|
|
@ -64,7 +64,6 @@ type Response {
|
||||||
|
|
||||||
type AdminLoginResponse {
|
type AdminLoginResponse {
|
||||||
message: String!
|
message: String!
|
||||||
access_token: String!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config {
|
type Config {
|
||||||
|
|
|
@ -105,7 +105,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,7 @@ func AdminLoginResolver(ctx context.Context, params model.AdminLoginInput) (*mod
|
||||||
utils.SetAdminCookie(gc, hashedKey)
|
utils.SetAdminCookie(gc, hashedKey)
|
||||||
|
|
||||||
res = &model.AdminLoginResponse{
|
res = &model.AdminLoginResponse{
|
||||||
AccessToken: hashedKey,
|
Message: "admin logged in successfully",
|
||||||
Message: "admin logged in successfully",
|
|
||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,7 @@ func AdminSession(ctx context.Context) (*model.AdminLoginResponse, error) {
|
||||||
utils.SetAdminCookie(gc, hashedKey)
|
utils.SetAdminCookie(gc, hashedKey)
|
||||||
|
|
||||||
res = &model.AdminLoginResponse{
|
res = &model.AdminLoginResponse{
|
||||||
AccessToken: hashedKey,
|
Message: "admin logged in successfully",
|
||||||
Message: "admin logged in successfully",
|
|
||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,8 +71,7 @@ func AdminSignupResolver(ctx context.Context, params model.AdminLoginInput) (*mo
|
||||||
utils.SetAdminCookie(gc, hashedKey)
|
utils.SetAdminCookie(gc, hashedKey)
|
||||||
|
|
||||||
res = &model.AdminLoginResponse{
|
res = &model.AdminLoginResponse{
|
||||||
AccessToken: hashedKey,
|
Message: "admin signed up successfully",
|
||||||
Message: "admin signed up successfully",
|
|
||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user