Hi, 

I'm using the excellent " basic auth plus " plugin to authenticate against 
an LDAP server.

It is being called from the hook "before_routes". 

Question : is it possible to insert a value into the stash from this hook ? 

I tried with $self->stash(user => $username) but it's not recognized by the 
template at rendering time from the main route ( get '/ ' )

*Global symbol "$user" requires explicit package name (did you forget to 
declare "my $user"?) at template index.html.ep from DATA section line 5.*


*Template*

__DATA__

@@index.html.ep
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><%= $user %></title>
...



*Sample code is below : *


app->hook(before_routes => sub {

        my $self = shift;
        my ($hash_ref, $auth_ok)
        = $self->basic_auth(
            "LDAP" => {
                [insert ldap config here]
            }
        );

        if ($hash_ref->{ldap}) {
my $ldap     = $hash_ref;
my $username = $hash_ref->{username};
                        $self->stash(user => $username);
[ ... ]
}

        return 0 unless $auth_ok; 
});

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to