Skip to content

Conversation

@markstory
Copy link
Member

I haven't forgotten about this. One day I might even be finished it.

@markstory markstory added this to the 3.x milestone Jul 18, 2017
@jeremyharris
Copy link
Member

I was just going to ask about this. Good timing 😄

I'll pull this tomorrow and continue running through it. I think I will start the complimentary testing tutorial soon.

'unauthorizedRedirect' => $this->referer()
]);

// Allow the display action so our pages controller
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pages?? or all controller(s)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is all controllers.

And in **src/Template/Users/login.ctp** add the following::

<h1>Login</h1>
<?= $this->Form->create() ?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is not better to use entity object here?
$this->Form->create($user)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no entity though.

Copy link
Member

@jeremyharris jeremyharris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! I once again tried to approach this as someone who's totally unfamiliar, so please forgive/ignore any verbosity I suggest.

// continues to work. Also enable the read only actions.
$this->Auth->allow(['display', 'view', 'index']);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this was baked, it has code it in at this point. Do you think including that code or a // existing code would be good? If using the // existing code, you can remove the FlashComponent as that is baked in. Here's the baked code if you want to include it instead:

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

        $this->loadComponent('RequestHandler');
        $this->loadComponent('Flash');

        /*
         * Enable the following components for recommended CakePHP security settings.
         * see http://book.cakephp.org/3.0/en/controllers/components/security.html
         */
        //$this->loadComponent('Security');
        //$this->loadComponent('Csrf');
    }

components. In addition, we've customized the configuration of AuthComponent, as
our users table uses ``email`` as the username. Now, if you go to any URL you'll
be redirected to **/users/login**, which will show an error page as we have
not written that code yet. So let's create the login action::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"any URL (other than our static pages and any read-only pages)"
or
"any protected URL, such as **/artlcles/add**"

The only reason I think we should note this is that hitting the homepage is "allowed" and may confuse people as to what they did wrong.

.. note::

If none of your users have hashed passwords, comment the
``loadComponent('Auth')`` line. Then go and edit the user,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"line" -> "block"

And maybe also need to note to uncomment the $this->Auth->allow() line, as the auth component would no longer be loaded.


If none of your users have hashed passwords, comment the
``loadComponent('Auth')`` line. Then go and edit the user,
saving a new password for them.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"After saving a new password for the user, make sure to uncomment the lines we just temporarily commented!"

saving a new password for them.

You should now be able to log in. If not, make sure you are using a user that
has a hashed password.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a new para:

"Try it out! Before logging in, visit **/articles/add**. Since this action is not allowed, you will be redirected to the login page. After logging in successfully, CakePHP will automatically redirect you back to **/articles/add**."

return $this->redirect($this->Auth->logout());
}

This code adds the ``logout`` action as one that does not require authentication
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"adds the ``logout`` action to the list of ones that do not"

@markstory
Copy link
Member Author

Thanks for the great feedback @jeremyharris

@markstory markstory merged commit 109aa42 into 3.0 Jul 21, 2017
@markstory markstory deleted the cms-tutorial branch July 21, 2017 01:42
markstory added a commit that referenced this pull request Aug 3, 2017
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

Successfully merging this pull request may close these issues.

6 participants