Skip to content

Commit

Permalink
bug on verify
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincobain2000 committed Jan 22, 2024
1 parent 109ed9b commit edcd28b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ runs:
-d '{
"org": "${{github.repository_owner}}",
"repo": "${{ github.event.repository.name }}",
"type": "${{ inputs.type }}"
"type": "${{ inputs.type }}",
"commit": "${{ github.sha }}"
}' \
"${{inputs.host}}/destroy"
Expand Down
9 changes: 5 additions & 4 deletions app/pkg/destroy_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ func NewDestroyHandler() *DestroyHandler {
}

type DestroyRequest struct {
Org string `json:"org" form:"org" validate:"required,ascii,excludes=/" message:"org is required"`
Repo string `json:"repo" form:"repo" validate:"required,ascii,excludes=/" message:"repo is required"`
Type string `json:"type" form:"type" validate:"ascii,excludes=/" message:"ascii type is required"`
Org string `json:"org" form:"org" validate:"required,ascii,excludes=/" message:"org is required"`
Repo string `json:"repo" form:"repo" validate:"required,ascii,excludes=/" message:"repo is required"`
Type string `json:"type" form:"type" validate:"ascii,excludes=/" message:"ascii type is required"`
Commit string `json:"commit" form:"commit" validate:"ascii,excludes=/" message:"ascii commit is required"`
}

func (h *DestroyHandler) Post(c echo.Context) error {
Expand All @@ -40,7 +41,7 @@ func (h *DestroyHandler) Post(c echo.Context) error {
}

if os.Getenv("GITHUB_API") != "" {
if err := h.github.VerifyGithubToken(c.Request().Header.Get("Authorization"), req.Org, req.Repo, req.Type); err != nil {
if err := h.github.VerifyGithubToken(c.Request().Header.Get("Authorization"), req.Org, req.Repo, req.Commit); err != nil {
return echo.NewHTTPError(http.StatusUnauthorized, err.Error())
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/pkg/upload_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (h *UploadHandler) Post(c echo.Context) error {

// set by default to api.github and "" on tests
if os.Getenv("GITHUB_API") != "" {
if err := h.github.VerifyGithubToken(c.Request().Header.Get("Authorization"), req.Org, req.Repo, req.Type); err != nil {
if err := h.github.VerifyGithubToken(c.Request().Header.Get("Authorization"), req.Org, req.Repo, req.Commit); err != nil {
return echo.NewHTTPError(http.StatusUnauthorized, err.Error())
}
}
Expand Down

0 comments on commit edcd28b

Please sign in to comment.