[rt-users] $self->SUPER::SetPassword() returns "0, Nonexistant field?" in User_Overlay.pm

Jesse Vincent jesse at bestpractical.com
Mon Sep 8 20:59:47 EDT 2008


On Sep 8, 2008, at 8:51 PM, Ole Craig wrote:

> On Sun, 2008-09-07 at 13:47 -0400, Jesse Vincent wrote:
>> On Sep 5, 2008, at 9:46 PM, Ole Craig wrote:
>>
>>> (rt 3.8.1rc5)
>>>
>>> I've got some custom functionality in a User_Local.pm file, trying
>> to
>>> call the SetPassword method from lib/RT/User_Overlay.pm. This method
>>> always returns ("0", "Nonexistant field?") when trying to get
>> results
>>> from a call to the method it's overriding; the call is around line
>> 893
>>> in User_Overlay.pm, in this block:
>>>
>>> my $new = !$self->HasPassword;
>>> $password = $self->_GeneratePassword($password);
>>> my ( $val, $msg ) = $self->SUPER::SetPassword($password);
>>> if ($val) {
>>>   return ( 1, $self->loc("Password set") ) if $new;
>>>   return ( 1, $self->loc("Password changed") );
>>> }
>>> else {
>>>   return ( $val, $msg );
>>> }
>>>
>>
>> Is your actual method called SetPassword? If so, then you need to be
>> calling _Set or __Set rather than SetPassword. If your method isn't
>> SetPassword, you just want to call SetPassword on the local object.
>
> Jesse -
>    My method is not called SetPassword; I believe I AM trying to call
> SetPassword on the local object and it's that call which seems to  
> fail.
> (Sorry, my previous message was needlessly confusing: I posted the  
> block
> of [bestpractical] code that appears to generate the error, not the
> block of code I wrote. In hindsight, I realize that was rather  
> arrogant
> of me. :-)
>
>    My ~rt/local/lib/RT/User_Local.pm contains two method overrides:
> ResetPassword() and IsPassword(). IsPassword() calls ResetPassword()
> which calls the stock SetRandomPassword() from User_Overlay.pm,  
> which in
> turn calls $self->SetPassword($pass). The "0, Nonexistant field?" is
> actually the return value from SetPassword() passed back through
> SetRandomPassword().
>
>    So the gist of my problem is that when the stock SetPassword is
> called on the local object with a string as argument, it barfs instead
> of setting the password to the string.
>
>    ...a loose approximation of a call stack:
> User_Overlay.pm: SetPassword() called with 1 argument from
> User_Overlay.pm: SetRandomPassword() called with no arguments from
> User_Local.pm:   ResetPassword() called with no arguments from
> User_Local.pm:   IsPassword()
>
> What I'm trying to accomplish: If a privileged user with an unset
> password (i.e. Users.Password = '*NO-PASSWORD*') attempts to log in, I
> want the web interface to act the same way that it would if an  
> incorrect
> password had been presented, but in the background a new random  
> password
> is set and the user gets an email containing that password.)
>
>    I had this working under 3.6.0. I've attached my User_Local.pm in
> case it helps clarify.
>



I have a sneaking suspicion that this is related to 3.8 switching  
CurrentUser to be a subclass of User rather than delegating to the user.

try creating a new RT::User object as the superuser, loading the  
current user's id and going from there.

-j



More information about the rt-users mailing list