checking if the account is a valid mail address

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/226/head
Maxence Lange 2018-12-19 19:24:05 -01:00
rodzic b7e3a6dc2b
commit 35be62836f
1 zmienionych plików z 6 dodań i 5 usunięć

Wyświetl plik

@ -92,14 +92,15 @@ class CurlService {
public function retrieveAccount(string $account): Person {
$account = $this->withoutBeginAt($account);
if (strstr(substr($account, 0, -3), '@') === false) {
// we consider an account is like an email
if (!filter_var($account, FILTER_VALIDATE_EMAIL)) {
throw new InvalidResourceException();
}
list($username, $host) = explode('@', $account);
// if ($username === null || $host === null) {
// throw new InvalidResourceException();
// }
list($username, $host) = explode('@', $account);
if ($username === null || $host === null) {
throw new InvalidResourceException();
}
$request = new Request('/.well-known/webfinger');
$request->addData('resource', 'acct:' . $account);