Skip to content

Commit

Permalink
fix: two step check for transfer op
Browse files Browse the repository at this point in the history
  • Loading branch information
cody committed Sep 18, 2024
1 parent 253838c commit e0a2a29
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions core/corehttp/corehttp_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

const defaultTwoStepDuration = 30 * time.Minute

const firstStepUrl = "/api/v1/dashboard/validate"
const firstStepUrl = "dashboard/validate"

func interceptorBeforeReq(r *http.Request, n *core.IpfsNode) error {
config, err := n.Repo.Config()
Expand All @@ -39,7 +39,7 @@ func interceptorBeforeReq(r *http.Request, n *core.IpfsNode) error {
}

func twoStepCheckInterceptor(r *http.Request) error {
if !needTwoStepCheckUrl(r.URL.Path) {
if !needTwoStepCheckUrl(r.Method, r.URL.Path) {
return nil
}
if currentStep == secondStep {
Expand Down Expand Up @@ -160,14 +160,17 @@ func passwordCheckInterceptor(r *http.Request) error {
return nil
}

if needTwoStepCheckUrl(r.URL.Path) && currentStep == secondStep {
if needTwoStepCheckUrl(r.Method, r.URL.Path) && currentStep == secondStep {
currentStep = firstStep
}

return nil
}

func needTwoStepCheckUrl(path string) bool {
func needTwoStepCheckUrl(method string, path string) bool {
if method == http.MethodOptions {
return false
}
urls := map[string]bool{
APIPath + "/bttc/send-btt-to": true,
APIPath + "/bttc/send-wbtt-to": true,
Expand Down

0 comments on commit e0a2a29

Please sign in to comment.