[rt-users] Forgotten password reminder options?

Dimitry Faynerman dimitry.faynerman at hypermediasystems.com
Wed Jun 30 13:21:57 EDT 2004


If you're using MySQL, there's probably no way to remind password since it's
MD5 encrypted. But here's how you can reset it and send to the user:


Dimitry




=========================================================================





<HTML>
<HEAD>
<META HTTP-EQUIV="Refresh"
CONTENT="0;URL=<%$RT::WebPath%>/NoAuth/Login.html?customMessage=<%$customMes
sage%>">
</HEAD>
<BODY>
</BODY>
</HTML>

<%INIT>

my $customMessage;

if ($email) {
  my $UserObj = RT::User->new($RT::SystemUser);

  $UserObj->LoadByEmail($email);

  if (defined($UserObj->Id)) {
    my ($val, $str) = ResetPassword($UserObj, $email);
    $customMessage = $str;
  }
  else {
    $customMessage = "No account matches that email address";
  }
}
else {
  $customMessage = "Please enter an email address";
}

sub ResetPassword {

    my $self = shift;
    my $email = shift;

    unless ( $self->CurrentUserCanModify('Password') ) {
        return ( 0, $self->loc("Permission Denied") );
    }
    my ( $status, $pass ) = $self->SetRandomPassword();

    unless ($status) {
        return ( 0, "$pass" );
    }

    my $template = RT::Template->new( $self->CurrentUser );

    $template->LoadGlobalTemplate('Password Change');

    $T::RealName = $self->RealName;
    $T::Username = $self->Name;
    $T::Password = $pass;

    my $parsed = $template->_ParseContent();


    my $entity = MIME::Entity->build(
                                      From => "dti-support\@dtiserv2.com",
                                      To => $email,
                                      Subject => loc("Trouble Ticket New
Password"),
                                      'X-RT-Loop-Prevention' => $RT::rtname,
                                      Type => "text/plain",
                                      Charset => "UTF-8",
                                      Data => [$parsed]
                                    );
    open (MAIL, "|$RT::SendmailPath $RT::SendmailArguments") || return(0);
    print MAIL $entity->as_string;
    close(MAIL);

    return ( 1, 'New password notification sent');
}



</%INIT>

<%ARGS>
$email => undef
</%ARGS>




More information about the rt-users mailing list