aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/faucet
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2018-02-22 19:20:36 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-02-22 19:20:36 +0800
commit72c4c50777fbd0e7232c4c0adff030954e3e46ba (patch)
treec2343e149cac466562b6ab80bfa496917274449b /cmd/faucet
parent1e457b659989478004329c2f3a82b5ac67b32cbf (diff)
downloaddexon-72c4c50777fbd0e7232c4c0adff030954e3e46ba.tar
dexon-72c4c50777fbd0e7232c4c0adff030954e3e46ba.tar.gz
dexon-72c4c50777fbd0e7232c4c0adff030954e3e46ba.tar.bz2
dexon-72c4c50777fbd0e7232c4c0adff030954e3e46ba.tar.lz
dexon-72c4c50777fbd0e7232c4c0adff030954e3e46ba.tar.xz
dexon-72c4c50777fbd0e7232c4c0adff030954e3e46ba.tar.zst
dexon-72c4c50777fbd0e7232c4c0adff030954e3e46ba.zip
cmd/faucet: resolve twitter user from final redirect
Diffstat (limited to 'cmd/faucet')
-rw-r--r--cmd/faucet/faucet.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/cmd/faucet/faucet.go b/cmd/faucet/faucet.go
index 99527f9d1..095668c86 100644
--- a/cmd/faucet/faucet.go
+++ b/cmd/faucet/faucet.go
@@ -686,8 +686,6 @@ func authTwitter(url string) (string, string, common.Address, error) {
if len(parts) < 4 || parts[len(parts)-2] != "status" {
return "", "", common.Address{}, errors.New("Invalid Twitter status URL")
}
- username := parts[len(parts)-3]
-
// Twitter's API isn't really friendly with direct links. Still, we don't
// want to do ask read permissions from users, so just load the public posts and
// scrape it for the Ethereum address and profile URL.
@@ -697,6 +695,13 @@ func authTwitter(url string) (string, string, common.Address, error) {
}
defer res.Body.Close()
+ // Resolve the username from the final redirect, no intermediate junk
+ parts = strings.Split(res.Request.URL.String(), "/")
+ if len(parts) < 4 || parts[len(parts)-2] != "status" {
+ return "", "", common.Address{}, errors.New("Invalid Twitter status URL")
+ }
+ username := parts[len(parts)-3]
+
body, err := ioutil.ReadAll(res.Body)
if err != nil {
return "", "", common.Address{}, err