// Initialize the Auth instance $auth = new \Delight\Auth\Auth($pdo); // Login with email and password try { $auth->login($_POST['email'], $_POST['password']); // Redirect to dashboard header('Location: /dashboard.php'); exit; } catch (\Delight\Auth\InvalidEmailException $e) { // Invalid email address } catch (\Delight\Auth\InvalidPasswordException $e) { // Invalid password } catch (\Delight\Auth\EmailNotVerifiedException $e) { // Email not verified } catch (\Delight\Auth\TooManyRequestsException $e) { // Too many failed login attempts }
// Initialize the Auth instance $auth = new \Delight\Auth\Auth($pdo); // Register a new user account try { $userId = $auth->register($_POST['email'], $_POST['password'], $_POST['username']); // Redirect to login page header('Location: /login.php'); exit; } catch (\Delight\Auth\InvalidEmailException $e) { // Invalid email address } catch (\Delight\Auth\InvalidPasswordException $e) { // Invalid password } catch (\Delight\Auth\UserAlreadyExistsException $e) { // User already exists with that email address } catch (\Delight\Auth\TooManyRequestsException $e) { // Too many failed registration attempts }In these examples, we can see that the code is using the Auth instance class from the \Delight\Auth namespace to handle user authentication and registration. The package library for this code is most likely Delight/Auth.