delight-im / PHP-Auth

Authentication for PHP. Simple, lightweight and secure.
MIT License
1.08k stars 234 forks source link

Invalid email address #260

Closed lmsvr closed 2 years ago

lmsvr commented 3 years ago

For some reason I can't register a first user to initiate the auth system, I keep getting the result: Invalid email address

I Verified User & Pass for database and successfully connecting What could I possibly be doing wrong?

Script below is after successful database connection...

require_once $GLOBALS['CORE_ROOT'] . '/vendor/autoload.php';

$auth = new \Delight\Auth\Auth($db);

try { $userId = $auth->admin()->createUser($_POST['test@test.com'], $_POST['test'], $_POST['test']);

echo 'We have signed up a new user with the ID ' . $userId;

} catch (\Delight\Auth\InvalidEmailException $e) { die('Invalid email address'); } catch (\Delight\Auth\InvalidPasswordException $e) { die('Invalid password'); } catch (\Delight\Auth\UserAlreadyExistsException $e) { die('User already exists'); }

eypsilon commented 3 years ago
 $userId = $auth->admin()->createUser($_POST['test@test.com'], $_POST['test'], $_POST['test']);

Check

error_reporting(E_ALL);

print $_POST['test@test.com'];
print $_POST['test'];

How do you set both?

lmsvr commented 3 years ago

Thanks for your reply,

The error reporting was in fact turned off as your 'hint' got me moving in the right direction... All is working now!

For anyone's reference as this may be viewed by others my solution was to add... ini_set('display_errors', 1);

as early as possible in my PHP code which displayed where my mistake was

ocram commented 2 years ago

Thanks, @eypsilon!

@lmsvr Thanks for reporting what worked for you.