NJ
Troca de senha sem acesso ao sistetema
Estou tentando fazer um form com troca de se senha sem acesso ao sistema. Mas dá um erro muito escroto que buga todo o sistema.
segue o código:
public function onSave($param)
{
try
{
$this->form->validate();
TTransaction::open('permission');
$object = $this->form->getData();
$user = SystemUser::newFromLogin($object->login));
if (SystemUser::newFromLogin($object->login) instanceof SystemUser)
{
if ($object->pergunta_secreta_id == $user->pergunta_secreta_id) and ( md5($object->resposta_secreta) == $user->resposta_secreta)
{
$user->password = md5($object->password);
}
}
else
{
throw new Exception(_t('Current CPF does not match'));
throw new Exception(_t('Current question does not match'));
throw new Exception(_t('Current question does not match'));
}
if ($object->repassword != $object->password)
{
throw new Exception(_t('New password does not match the confirm password'));
}
// stores the object
$user->store();
// fill the form with the active record data
$this->form->setData($object);
// close the transaction
TTransaction::close();
// shows the success message
new TMessage('info', _t('Password changed successfully'));
}
catch (Exception $e)
{
new TMessage('error', $e->getMessage());
TTransaction::rollback();
}
}
public static function onReload()
{
AdiantiCoreApplication::gotoPage('RecuperaSenhaForm', '');
}
}
segue o código:
public function onSave($param)
{
try
{
$this->form->validate();
TTransaction::open('permission');
$object = $this->form->getData();
$user = SystemUser::newFromLogin($object->login));
if (SystemUser::newFromLogin($object->login) instanceof SystemUser)
{
if ($object->pergunta_secreta_id == $user->pergunta_secreta_id) and ( md5($object->resposta_secreta) == $user->resposta_secreta)
{
$user->password = md5($object->password);
}
}
else
{
throw new Exception(_t('Current CPF does not match'));
throw new Exception(_t('Current question does not match'));
throw new Exception(_t('Current question does not match'));
}
if ($object->repassword != $object->password)
{
throw new Exception(_t('New password does not match the confirm password'));
}
// stores the object
$user->store();
// fill the form with the active record data
$this->form->setData($object);
// close the transaction
TTransaction::close();
// shows the success message
new TMessage('info', _t('Password changed successfully'));
}
catch (Exception $e)
{
new TMessage('error', $e->getMessage());
TTransaction::rollback();
}
}
public static function onReload()
{
AdiantiCoreApplication::gotoPage('RecuperaSenhaForm', '');
}
}
Que erro?
resolvi de forma diferente. reorganizei este código .