[prev in list] [next in list] [prev in thread] [next in thread] 

List:       djabberd
Subject:    Re: Get the vhost info in auth module
From:       Martin Atkins <mart () degeneration ! co ! uk>
Date:       2009-07-28 15:44:35
Message-ID: 4A6F1CE3.1090704 () degeneration ! co ! uk
[Download RAW message or body]

Rohan Almeida wrote:
> 
> In My/Auth.pm
> 
> sub check_cleartext {
>       my ($self, $cb, %args) = @_;
>       my $username = $args{username};
>       my $password = $args{password};
>       my $conn = $args{conn};
> 
> }
> 
> So I get the username, password and the $conn ISA 
> DJabberd::Connection::ClientIn
> 
> I can see that I get all the vhosts using:
> 
> my $vhosts = $conn->server->vhosts;
> 
> but how I do know which vhost is currently connecting?
> 

Although it's not passed into the check methods, the vhost is passed 
into the "register" method, so you could override that and stash the 
result in your plugin object like this:

sub register {
     my ($self, $vhost) = @_;

     $self->SUPER::register($vhost);
     $self->{__my_auth_vhost} = $vhost;
}

Since you get a separate instance of a plugin for each <Plugin> 
declaration in the config file it's okay to tie your instance to the 
vhost like this, as long as you make it an instance property rather than 
a global.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic