{"id":19571761,"url":"https://github.com/loadsys/cakephp-auth-userentity","last_synced_at":"2025-04-27T03:32:37.731Z","repository":{"id":62518495,"uuid":"47582699","full_name":"loadsys/CakePHP-Auth-UserEntity","owner":"loadsys","description":"A CakePHP 3 plugin that enhances Cake's stock AuthComponent to provide a userEntity() method.","archived":false,"fork":false,"pushed_at":"2015-12-08T14:39:41.000Z","size":11,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-04T20:51:22.374Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loadsys.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-07T22:16:54.000Z","updated_at":"2022-01-01T15:42:43.000Z","dependencies_parsed_at":"2022-11-02T10:45:33.416Z","dependency_job_id":null,"html_url":"https://github.com/loadsys/CakePHP-Auth-UserEntity","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loadsys%2FCakePHP-Auth-UserEntity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loadsys%2FCakePHP-Auth-UserEntity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loadsys%2FCakePHP-Auth-UserEntity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loadsys%2FCakePHP-Auth-UserEntity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loadsys","download_url":"https://codeload.github.com/loadsys/CakePHP-Auth-UserEntity/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251085145,"owners_count":21533821,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T06:19:56.797Z","updated_at":"2025-04-27T03:32:37.434Z","avatar_url":"https://github.com/loadsys.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CakePHP-Auth-UserEntity\n\n[![Latest Version](https://img.shields.io/github/release/loadsys/CakePHP-Auth-UserEntity.svg?style=flat-square)](https://github.com/loadsys/CakePHP-Auth-UserEntity/releases)\n[![Build Status](https://img.shields.io/travis/loadsys/CakePHP-Auth-UserEntity/master.svg?style=flat-square)](https://travis-ci.org/loadsys/CakePHP-Auth-UserEntity)\n[![Coverage Status](https://img.shields.io/coveralls/loadsys/CakePHP-Auth-UserEntity/master.svg?style=flat-square)](https://coveralls.io/r/loadsys/CakePHP-Auth-UserEntity)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![Total Downloads](https://img.shields.io/packagist/dt/loadsys/cakephp-auth-userentity.svg?style=flat-square)](https://packagist.org/packages/loadsys/cakephp-auth-userentity)\n\nA CakePHP 3 plugin that enhances Cake's stock AuthComponent to provide a userEntity() method.\n\n\n## Requirements\n\n* CakePHP 3.0.0+\n* PHP 5.6+\n\n\n## Installation\n\nPull the plugin into your project using composer:\n\n```bash\n$ composer require loadsys/cakephp-auth-userentity:~1.0\n```\n\nTo use this plugin in your app, you must override the stock AuthComponent with the one from this plugin. This is typically done in `AppController::initialize()`:\n\n```php\n$this-\u003eloadComponent('Auth', [\n\t/**\n\t * Name the plugin's Component as the class to use. This is **required**\n\t * in order to use the plugin.\n\t */\n\t'className' =\u003e 'AuthUserEntity.UserEntityAuth',\n\n\t/**\n\t * Name the Entity class that will be used as the container for the\n\t * array data in Auth-\u003euser(). Defaults to `\\Cake\\ORM\\Entity`, which\n\t * is safe for all apps, but will exclude any custom logic you may\n\t * have defined in your app's \"user\" Entity class.\n\t */\n\t'entityClass' =\u003e '\\App\\Model\\Entity\\User',\n\n\t/**\n\t * Any options to pass to the new Entity when it is created. The defaults\n\t * are:\n\t *\n\t *   [\n\t *       'markClean' =\u003e true,    // Force the Entity to appear clean.\n\t *       'source' =\u003e 'AuthUser', // The repository this record originated from.\n\t *                               // We default to a fake name to make it clear\n\t *                               // the Entity doesn't represent a \"true\" ORM\n\t *                               // record.\n\t *   ]\n\t */\n\t'entityOptions' =\u003e [\n\t\t'associated' =\u003e ['Permissions', 'Groups'],\n\t],\n\n\t/**\n\t * (The rest of your normal Auth configs follow here.)\n\t */\n\t// ...\n]);\n```\n\n## Usage\n\nOnce installed, you will be able to retrieve a User entity from your controllers like so:\n\n```php\n\t// Get the whole entity:\n\t$user = $this-\u003eAuth-\u003euserEntity();\n\n\t// Or to get a specific property (which will engage any\n\t// _getProperty() methods you have defined in your Entity class):\n\t$userEmail = $this-\u003eAuth-\u003euserEntity('email');\n\n\t// Internally, the Entity::get() interface is used, so you can pass\n\t// nested keys (but remember that this data must be loaded into the\n\t// Auth session data!):\n\t$groupName = $this-\u003eAuth-\u003euserEntity('group.name');\n\n\t// Or to call a function from your entity:\n\tif (!$this-\u003eAuth-\u003euserEntity()-\u003eisAdmin()) {\n\t\t$this-\u003eFlash-\u003eerror('Only admins can use this method.');\n\t\treturn $this-\u003eredirect('/');\n\t}\n```\n\nLike the stock AuthComponent's `::user()` method, `null` will be returned whenever there is no authenticated User data available in the Session. It's also important to remember that **only** the data that is saved into the Auth session will be available in the Entity, but you can use [lazy loading in the Entity class](http://book.cakephp.org/3.0/en/orm/entities.html#lazy-loading-associations) to fetch additional properties as needed or [adjust the find query](http://book.cakephp.org/3.0/en/controllers/components/authentication.html#customizing-find-query) used to authenticate users so associated data is available in the Auth session.\n\nAlso keep in mind that currently **only** the top-level data is [marshaled](http://book.cakephp.org/3.0/en/orm/saving-data.html#converting-request-data-into-entities), so sub-properties will exist only as arrays and not Entities themselves.\n\n\n## Contributing\n\n### Reporting Issues\n\nPlease use [GitHub Isuses](https://github.com/loadsys/CakePHP-Auth-UserEntity/issues) for listing any known defects or issues.\n\n### Development\n\nWhen developing this plugin, please fork and issue a PR for any new development.\n\n## License\n\n[MIT](https://github.com/loadsys/CakePHP-Auth-UserEntity/blob/master/LICENSE.md)\n\n\n## Copyright\n\n[Loadsys Web Strategies](http://www.loadsys.com) 2015\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floadsys%2Fcakephp-auth-userentity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floadsys%2Fcakephp-auth-userentity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floadsys%2Fcakephp-auth-userentity/lists"}