From 66d9a425cb6cbbc459efb482edbe3c0fab41f4ed Mon Sep 17 00:00:00 2001 From: Paul Flo Williams Date: Tue, 9 Dec 2025 17:11:35 +0000 Subject: [PATCH] Make sure db handle is fresh when logging in, checking roles and creating users --- lib/Dancer2/Plugin/Auth/Extensible/Provider/Database.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Dancer2/Plugin/Auth/Extensible/Provider/Database.pm b/lib/Dancer2/Plugin/Auth/Extensible/Provider/Database.pm index d7d0447..9b23362 100644 --- a/lib/Dancer2/Plugin/Auth/Extensible/Provider/Database.pm +++ b/lib/Dancer2/Plugin/Auth/Extensible/Provider/Database.pm @@ -355,9 +355,11 @@ sub create_user { my $username = delete $options{username} or croak "username needs to be specified for create_user"; + my $database = $self->plugin_database($self->db_connection_name); + # password column might not be nullable so set to empty since we fail # auth attempts for empty passwords anyway - my $ret = $self->database->quick_insert( $self->users_table, + my $ret = $database->quick_insert( $self->users_table, { $self->users_username_column => $username, password => '', %options } ); return $ret ? $self->get_user_details($username) : undef; @@ -375,7 +377,7 @@ sub get_user_details { unless defined $username; # Get our database handle and find out the table and column names: - my $database = $self->database; + my $database = $self->plugin_database($self->db_connection_name); # Look up the user, my $user = $database->quick_select( @@ -396,7 +398,7 @@ sub get_user_details { sub get_user_roles { my ($self, $username) = @_; - my $database = $self->database; + my $database = $self->plugin_database($self->db_connection_name); # Get details of the user first; both to check they exist, and so we have # their ID to use.