In certain circumstances Member::CurrentUser() no returns an object, so Member::CurrentUser()->Email fails.
It is desirable to control this situation.
The correct code can be:
EmailVerifiedMember.php
function onBeforeWrite() {
if (!$this->owner->VerificationString) {
$this->owner->VerificationString = MD5(rand());
}
if (!$this->owner->Verified) {
if ((!$this->owner->VerificationEmailSent)) {
$this->owner->sendemail($this->owner, false);
}
$uid = Member::currentUserID(); // <<<<
$oemail = $this->owner->Email; // <<<<
$cuser = Member::currentUser(); // <<<<
if ($uid && $cuser && ($oemail == $cuser->Email)) { // <<<<
//if (Member::currentUserID() && ($this->owner->Email == Member::currentUser()->Email)) {
parent::onBeforeWrite();
Security::logout(false);
if (Director::redirected_to() == null) {
$messageSet = array(
'default' => _t('EmailVerifiedMember.EMAILVERIFY','Please verify your email address by clicking on the link in the email before logging in.'),
);
}
Session::set("Security.Message.type", 'bad');
Security::permissionFailure($this->owner, $messageSet);
} else return;
}
parent::onBeforeWrite();
}
Hi!
In certain circumstances Member::CurrentUser() no returns an object, so Member::CurrentUser()->Email fails.
It is desirable to control this situation.
The correct code can be:
EmailVerifiedMember.php
Regards,
Jose