Haha, sorry, that was not the case I adapted $identity to $id, but I quoted your original. Otherwise I would have had an easy unknown variable error, I assume
was written assuming you are in the Controller. Possibly the request property is available in the template also. (I typically use $this->getRequest() which I know is common to both locations).
At any rate, whichever place you acquire the object, it will be the same object. So, as long as you get it in a valid way the rest of the code will work.
Have you verified your are properly logged in? The request attributes array should have several keys on it that were written by the Authentication process:
You should see 1, 2, and 3 and they should be loaded with objects. I believe the authenticationResult object has a method to report the result of the login attempt and what strategy succeeded.
The identity should, of course, have your identity object in it.
Simple confirmations can be surprisingly useful . This was indeed the issue, so I have quickly resolved it (and applied it for delete as well):
<?php if($identity) {
if ($identity->can('edit', $article)){echo $this->Html->link(__('Edit'), ['action' => 'edit', $article->id]);}
} ?>