Skip to content

Commit

Permalink
Remove debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanTinianov committed Aug 10, 2023
1 parent 00197ee commit 08a113c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 16 deletions.
13 changes: 0 additions & 13 deletions resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package playground

import (
"context"
"fmt"
"github.com/Masterminds/semver"
"github.com/dapperlabs/flow-playground-api/adapter"
"github.com/dapperlabs/flow-playground-api/auth"
Expand Down Expand Up @@ -95,30 +94,23 @@ type mutationResolver struct {
}

func (r *mutationResolver) authorize(ctx context.Context, ID uuid.UUID) error {
fmt.Println("authorize()")
proj, err := r.projects.Get(ID)
if err != nil {
fmt.Println("Failed to get project:", err.Error())
return errors.Wrap(err, "failed to get project")
}

fmt.Println("authorize(): Check Project Access")
if err := r.auth.CheckProjectAccess(ctx, proj); err != nil {
fmt.Println("Project access not authorized:", err.Error())
return userErr.NewUserError("not authorized")
}

fmt.Println("No authorize error")
return nil
}

func (r *mutationResolver) CreateProject(ctx context.Context, input model.NewProject) (*model.Project, error) {
user, err := r.auth.GetOrCreateUser(ctx)
if err != nil {
fmt.Println("Failed to get or create user in CreateProject()")
return nil, errors.Wrap(err, "failed to get or create user")
}
fmt.Println("CreateProject() user is: ", user.ID.String())

proj, err := r.projects.Create(user, input)
if err != nil {
Expand All @@ -131,22 +123,17 @@ func (r *mutationResolver) CreateProject(ctx context.Context, input model.NewPro
}

func (r *mutationResolver) UpdateProject(ctx context.Context, input model.UpdateProject) (*model.Project, error) {
fmt.Println("Update Project()")
err := r.authorize(ctx, input.ID)
if err != nil {
fmt.Println("Update Project(): Failed to authorize:", err.Error())
return nil, err
}
fmt.Println("Update Project(): Authorized successfully")

if err := validateUpdate(&input); err != nil {
fmt.Println("Failed to Validation Update:", err.Error())
return nil, err
}

proj, err := r.projects.Update(input)
if err != nil {
fmt.Println("Failed to update project: ", err.Error())
return nil, errors.Wrap(err, "failed to update project")
}

Expand Down
3 changes: 0 additions & 3 deletions storage/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ func newSQL(dial gorm.Dialector, level logger.LogLevel) *SQL {
}

func migrate(db *gorm.DB) {
fmt.Println("Running database auto migration")
err := db.AutoMigrate(
&model.Project{},
&model.File{},
Expand Down Expand Up @@ -145,7 +144,6 @@ func (s *SQL) CreateProject(proj *model.Project, files []*model.File) error {
}

func (s *SQL) ProjectAccessed(id uuid.UUID) error {
fmt.Println("SQL: ProjectAccessed()")
update := make(map[string]any)
update["accessed_at"] = time.Now()
return s.db.Model(&model.Project{ID: id}).Updates(update).Error
Expand Down Expand Up @@ -270,7 +268,6 @@ func (s *SQL) DeleteProject(id uuid.UUID) error {
}

func (s *SQL) GetProject(id uuid.UUID, proj *model.Project) error {
fmt.Println("SQL: GetProject()")
return s.db.First(proj, id).Error
}

Expand Down

0 comments on commit 08a113c

Please sign in to comment.