$this->jerr("Invalid request to reset password");
}
- $this->verifyCheckSum($_REQUEST['id'], $_REQUEST['ts'], $_REQUEST['key']);
+ $this->verifyResetPassword($_REQUEST['id'], $_REQUEST['ts'], $_REQUEST['key']);
+ $this->jok("Checksum is ok");
}
// this is 'classic' change password...
}
}
- //$u->active = 1;
+ // this was removed before - not quite sure why.
+ // when a duplicate login account is created, this stops the old one from interfering..
+ $u->active = 1;
// empty username = not really a hacking attempt.
// sort out sender.
$cm = DB_DataObject::factory('core_email');
if (!$cm->get('name', 'ADMIN_PASSWORD_RESET')) {
- $this->jerr("no template ADMIN_PASSWORD_RESET exists - please run importer ");
-
+ $this->jerr("no template Admin password reset (ADMIN_PASSWORD_RESET) exists - please run importer ");
}
+ if (!$cm->active) {
+ $this->jerr("template for Admin password reset has been disabled");
+ }
/*
$g = DB_DAtaObject::factory('Groups');
$sent = $mailer->send();
if (is_a($sent,'PEAR_Error') ) {
$this->addEvent('SYSERR',false, $sent->getMessage());
- $this->jerr($ret->getMessage());
+ $this->jerr($sent->getMessage());
}
$this->addEvent('PASSREQ',$u, $u->email);
}
-
- function resetPassword($id,$t, $key, $newpass )
+ function verifyResetPassword($id,$t, $key)
{
-
- $au = $this->getAuthUser();
+ $au = $this->getAuthUser();
+ print_R($au);
if ($au) {
- return "Already Logged in - no need to use Password Reset";
+ $this->jerr( "Already Logged in - no need to use Password Reset");
}
$u = DB_DataObject::factory('core_person');
// validate key..
if ($key != $u->genPassKey($t)) {
- $this->jerr("Password reset link is not valid ($key)");
+ $this->jerr("Password reset link is not valid (key)");
}
if ($t < strtotime("NOW - 1 DAY")) {
$this->jerr("Password reset link has expired");
}
+ return $u;
+
+
+
+ }
+
+
+ function resetPassword($id,$t, $key, $newpass )
+ {
+
+ $u = $this->verifyResetPassword($id,$t,$key);
+
$uu = clone($u);
$u->no_reset_sent = 0;
$u->setPassword($newpass);
}
$u->update($uu);
- $u->login();
+ $this->addEvent("CHANGEPASS", $u);
+
$this->jok("Password has been Updated");
}