Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Member::currentUser()->Email problem #4

Open
ghost opened this issue Jun 8, 2012 · 0 comments
Open

Member::currentUser()->Email problem #4

ghost opened this issue Jun 8, 2012 · 0 comments

Comments

@ghost
Copy link

ghost commented Jun 8, 2012

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

    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();
    }

Regards,
Jose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants