require_once 'vendor/autoload.php'; use Delight\Auth\Auth; $auth = new Auth($pdo); try { $auth->login($_POST['email'], $_POST['password']); // user is logged in } catch (\Delight\Auth\InvalidEmailException $e) { // wrong email address } catch (\Delight\Auth\InvalidPasswordException $e) { // wrong password } catch (\Delight\Auth\EmailNotVerifiedException $e) { // email not verified } catch (\Delight\Auth\TooManyRequestsException $e) { // too many requests }
require_once 'vendor/autoload.php'; use Delight\Auth\Auth; $auth = new Auth($pdo); try { $userId = $auth->register($_POST['email'], $_POST['password'], null, function ($selector, $token) { // send confirmation email }); // user registered successfully } catch (\Delight\Auth\InvalidEmailException $e) { // invalid email address } catch (\Delight\Auth\InvalidPasswordException $e) { // invalid password } catch (\Delight\Auth\UserAlreadyExistsException $e) { // user already exists } catch (\Delight\Auth\TooManyRequestsException $e) { // too many requests }Package library: Delight/Auth - This is a PHP library for authentication and authorization. It provides a set of easy-to-use functions and classes that can be integrated into any PHP project to manage user authentication, registration, and access control.