[dancer-users] Dancer2::Plugin::Auth::Extensible with DB

Nathan Bailey web at polynate.net
Thu Nov 23 11:38:39 GMT 2017


As far as I can tell, the module is actually incomplete. Try the following
patch:

--- /Library/Perl/5.18/Dancer2/Plugin/Auth/Extensible/Provider/Database.pm
2016-11-04
20:50:52.000000000 +1100
+++ Database.pm 2017-11-23 22:37:21.000000000 +1100
@@ -375,7 +375,8 @@
       unless defined $username;

     # Get our database handle and find out the table and column names:
-    my $database = $self->database;
+    #my $database = $self->database;
+    my $database = $self->plugin_database($self->db_connection_name); #
Per
https://github.com/PerlDancer/Dancer2-Plugin-Auth-Extensible-Provider-Database/issues/3

     # Look up the user,
     my $user = $database->quick_select(
@@ -389,6 +390,28 @@
     }
 }

+sub get_user_by_code {
+    my ($self, $code) = @_;
+    croak "code must be defined"
+      unless defined $code;
+
+    # 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); #
Per
https://github.com/PerlDancer/Dancer2-Plugin-Auth-Extensible-Provider-Database/issues/3
+
+    # Get just the username of the user with the matching pw_reset_code
+    my $user = $database->quick_lookup(
+        $self->users_table, { 'pw_reset_code' => $code }, 'email'
+    );
+
+    if (!$user) {
+        $self->plugin->app->log("debug", "No such code $code");
+        return;
+    } else {
+        return $user;
+    }
+}
+
 =head2 get_user_roles $username

 =cut
@@ -396,7 +419,8 @@
 sub get_user_roles {
     my ($self, $username) = @_;

-    my $database = $self->database;
+    #my $database = $self->database;
+    my $database = $self->plugin_database($self->db_connection_name); #
Per
https://github.com/PerlDancer/Dancer2-Plugin-Auth-Extensible-Provider-Database/issues/3

     # Get details of the user first; both to check they exist, and so we
have
     # their ID to use.

cheers,
Nathan

On 23 November 2017 at 22:10, Andrew Beverley <andy at andybev.com> wrote:

> On Thu, 23 Nov 2017 10:28:31 +0000 Clive Eisen wrote:
> > However the login is failing and I am just returned to the login screen
> > with the banner set to LOGIN FAILED
> >
> > There is no indication WHAT is failing - can anyone suggest either what
> > is wrong or where I can add debug - I have tried with and without roles.
>
> I would start by hacking some debug statements directly into the
> authenticate_user() subroutine in Provider/Database.pm
>
> That function should be called by DPAE, so you can check firstly that
> it's actually being called, and secondly if/what/why it's returning a
> failure (assuming it is).
>
> Andy
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20171123/2e1ac8ad/attachment.html>


More information about the dancer-users mailing list