Skip to content

Commit

Permalink
detect html unauthorized response and display an error message to ren…
Browse files Browse the repository at this point in the history
…ew auth token
  • Loading branch information
ogazitt committed Apr 29, 2020
1 parent edb90de commit 9c9d031
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"program": "${workspaceFolder}/main.go",
"env": {},
// "args": ["active", "logs", "1585955316987", "details", "1587147792662", "-f", "json"]
"args": ["connect", "aws"]
"args": ["active", "list"]
}
]
}
7 changes: 7 additions & 0 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,12 @@ func call(path string, verb string, payload interface{ io.Reader }) ([]byte, err
os.Exit(1)
}

// check for an HTML response which would indicate an error
html := string(contents[0:15])
if html == "<!DOCTYPE html>" {
fmt.Println("snap: token expired; please log in again")
os.Exit(1)
}

return contents, nil
}

0 comments on commit 9c9d031

Please sign in to comment.