Jump to content

password protected page


MTPockets

Recommended Posts

You may need to override an existing controller / creating a new one with something like the following in it:

//semi-pseudo code

public function initContent() {
    parent::initContent();

    if ($this->context->cookie->canViewPasswordProtectedPage) {
        //get the stuff you need
        //...
        $this->setTemplate('template-to-show.tpl');
    }
    else {
        $this->setTemplate('template-of-login-form.tpl');
    }
}


public function postProcess() {
    parent::postProcess();

    if (Tools::isSubmit('checkPasswordProtectedPagePassword') && Tools::getValue('passwd') === YOUR_PASSWORD) {
        $this->context->cookie->canViewPasswordProtectedPage = true;
        $this->context->cookie->write();
    }
}

I didn't tested but it's just an hint.

This assumes you want to save the login in the cookie.

Link to comment
Share on other sites

  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...