Concierge-Auth
view release on metacpan or search on metacpan
examples/02-user-management.pl view on Meta::CPAN
printf "Auth deleted user: %s\n", $auth_deleted ? "â still works (BAD)" : "â disabled (GOOD)";
}
# Try to delete non-existent user
print "\nTrying to delete non-existent user:\n";
my ($bad_delete, $bad_delete_msg) = $auth->deleteID('eve');
printf "Delete 'eve': %s\n", $bad_delete ? "â success (unexpected)" : "â failed: $bad_delete_msg";
print "\n--- Duplicate Registration Prevention ---\n";
# Try to register existing user
my ($dup_success, $dup_msg) = $auth->setPwd('alice', 'another_password');
printf "Register existing 'alice': %s\n",
$dup_success ? "â allowed (unexpected)" : "â prevented: $dup_msg";
# Verify original password still works if duplicate was prevented
if (!$dup_success) {
my $original_still_works = $auth->checkPwd('alice', 'new_secure_password');
printf "Original password: %s\n",
$original_still_works ? "â unchanged" : "â corrupted (BAD)";
}
print "\n--- Final User Status ---\n";
my @final_check = qw(alice bob charlie david eve);
for my $username (@final_check) {
my $exists = $auth->checkID($username);
printf "%-10s: %s\n", $username, $exists ? "exists" : "not found";
}
print "\n=== Example Complete ===\n";
__END__
=head1 KEY CONCEPTS DEMONSTRATED
=over 4
=item * Password resets completely replace old passwords
=item * Deleted users cannot authenticate or be found
=item * Operations on non-existent users fail gracefully
=item * Duplicate registrations are prevented
=item * All operations return both success status and descriptive messages
=back
=head1 BEST PRACTICES
=over 4
=item * Always check return values from user management operations
=item * Verify operations succeeded before proceeding
=item * Handle error messages appropriately for your application
=item * Test that old credentials no longer work after resets/deletions
=back
=head1 SEE ALSO
L<Concierge::Auth>, 01-basic-authentication.pl, 03-token-generation.pl
=cut
( run in 0.499 second using v1.01-cache-2.11-cpan-d06a3f9ecfd )