PHP code example of loadsys / cakephp-stateless-auth
1. Go to this page and download the library: Download loadsys/cakephp-stateless-auth library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
/**
* Allow the logged-in User to view their own record.
*
* @return void
* @throws NotFoundException If the passed id record does not exist
*/
public function view() {
$id = $this->Auth->user('id'); // <-- Populated by the stateless auth component.
if (!$id) {
throw new NotFoundException(__('Please log in to view your User record.'));
}
$options = array(
'conditions' => array(
'User.' . $this->User->primaryKey => $id,
),
);
$user = $this->User->find('first', $options);
$this->set(compact('user'));
}
public function isAuthorized($user) {
return true;
}