X-Git-Url: https://git.cweiske.de/shpub.git/blobdiff_plain/225b3ebc519d651dd2fda1b000483961352f2e84..020931dc98a4cace798a99d312b606b350b0ef9a:/src/shpub/Command/Connect.php diff --git a/src/shpub/Command/Connect.php b/src/shpub/Command/Connect.php index b59de5c..02f60c7 100644 --- a/src/shpub/Command/Connect.php +++ b/src/shpub/Command/Connect.php @@ -16,6 +16,14 @@ class Command_Connect public function run($server, $user, $newKey, $force) { + $server = Validator::url($server, 'server'); + if ($user === null) { + //indieweb: homepage is your identity + $user = $server; + } else { + $user = Validator::url($user, 'user'); + } + $host = $this->getHost($newKey != '' ? $newKey : $server, $force); if ($host === null) { //already taken @@ -90,6 +98,12 @@ class Command_Connect ) ); $res = $req->send(); + if (intval($res->getStatus() / 100) !== 2) { + Log::err('Failed to fetch access token'); + Log::err('Server responded with HTTP status code ' . $res->getStatus()); + Log::err($res->getBody()); + exit(2); + } if ($res->getHeader('content-type') != 'application/x-www-form-urlencoded') { Log::err('Wrong content type in auth verification response'); exit(2);