{"id":22908844,"url":"https://github.com/ipunkt/auth","last_synced_at":"2025-04-01T09:53:08.882Z","repository":{"id":20677834,"uuid":"23960772","full_name":"ipunkt/auth","owner":"ipunkt","description":"Pull in - Add additional user fields to config - migrate - Users. Uses Laravel 4","archived":false,"fork":false,"pushed_at":"2015-02-25T07:48:43.000Z","size":660,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-07T05:27:34.072Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ipunkt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-12T13:01:07.000Z","updated_at":"2015-02-20T14:11:34.000Z","dependencies_parsed_at":"2022-07-21T20:18:12.647Z","dependency_job_id":null,"html_url":"https://github.com/ipunkt/auth","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipunkt%2Fauth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipunkt%2Fauth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipunkt%2Fauth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipunkt%2Fauth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ipunkt","download_url":"https://codeload.github.com/ipunkt/auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246620237,"owners_count":20806721,"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-12-14T03:32:35.514Z","updated_at":"2025-04-01T09:53:08.864Z","avatar_url":"https://github.com/ipunkt.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ipunkt/auth\n\n[![Latest Stable Version](https://poser.pugx.org/ipunkt/auth/v/stable.svg)](https://packagist.org/packages/ipunkt/auth) [![Latest Unstable Version](https://poser.pugx.org/ipunkt/auth/v/unstable.svg)](https://packagist.org/packages/ipunkt/auth) [![License](https://poser.pugx.org/ipunkt/auth/license.svg)](https://packagist.org/packages/ipunkt/auth) [![Total Downloads](https://poser.pugx.org/ipunkt/auth/downloads.svg)](https://packagist.org/packages/ipunkt/auth)\n\nThis package provides a user model and simple login, plus remind and register views.\nIt integrates nicely with other ipunkt packages like [ipunkt/roles](https://github.com/ipunkt/roles) and [ipunkt/social-auth](https://github.com/ipunkt/social-auth) to provide a pull-in-and-use-it environment.\n\n## Installation\n\nAdd to your composer.json following lines\n\n\t\"require\": {\n\t\t\"ipunkt/auth\": \"1.*\"\n\t}\n\n## Configuration\n\n- Add \n\n        'Ipunkt\\Auth\\AuthServiceProvider'\n    \n    to your service provider list.  \n- Publish the config by doing\n\n        `php artisan config:publish ipunkt/auth`\n\t\n- Edit the `user_table` config file to suit your needs\n  - `table_name` - The name the table will go by in the database\n  - `login_through_field` - Which field is used to identify the user for login. Default is email. Username is also common\n  - `extra_fields` - Array of additional fields which you want your user model to have. Each field should have the following keys\n    - `name` - The field name in the Database\n    - `database_type` - The field type in the database\n    - `form_type` - The input type to use in the register and edit form\n    - `validation_rules` - The laravel Validator rules to validate this field when registering or editing\n    - `not during register` - if set to true then this field will not be available during registration. Only when editing\n      the user\n- Migrate the user table by doing\n\n        `php artisan migrate --package=ipunkt/auth`\n        \n### Registration strategy\n\nThe registration strategy can be choosen in the `config.php` through the field `registration_strategy`\n\n#### Single-opt-in\nCurrently only single-opt-in is provided by the package. This means the user will be logged in and activated once they\nsend valid user data to register.\nConfig Value: `single_opt_in`\n\n#### Double-opt-in\nIn the future a native double-opt-in will be provided. This means the user will be created, but disabled after they send\nvalid user data. An email will be sent to their email address with a confirmation link. Their user account will be enabled\nonce the registration link has been visited\nConfig Value: `double_opt_in`\n\n## Usage\n\nLink your users to the route `auth.register` to allow them to register\n\nLink your users to the route `auth.login` for logging a user in\n\nLink your users to the route `auth.logout` for logging a user out\n\n### User index\nIf you wish to publish a list of all users you can use to the auth.user.login route.\nThere are 3 ways to decide access to this:\n\n- If you set the `publish_user_index` to `true` in this packages config then everyone will be able to view it.\n- Otherwise if a user is logged in, it will be asked for permission to `index` on itself `Auth::user()-\u003ecan('index', Auth::user())`.\n  - If you use the `PermissionChecker` which is included in this package then adding `index` to the `user_actions` array will grant access to all users\n  - If you wish for a more complicated behaviour, simply bring your own `PermissionChecker` for your user model. See [ipunkt/permissions](https://github.com/ipunkt/permissions) for detail\n- If you neither set `publish_user_index` nor allow `index` in your user models `PermissionChecker` then it will fail through `App::abort(403)`\n\nThe default behaviour is to deny access.\n\n### User edit\nTo let your users edit a profile link them to the `auth.user.edit` route, with the user id / `$user-\u003egetKey()` as Parameter\n\nThis will ask the User model for `edit` permission\n\n  - If you use the `PermissionChecker` which is included in this package then adding `edit` to the `user_actions` array will grant permission to edit the users _own_ profile\n  - If you wish for a more complicated behaviour, simply bring your own `PermissionChecker` for your user model. See [ipunkt/permissions](https://github.com/ipunkt/permissions) for detail\n\nThe default behaviour is to allow editing permissions to the users own profile.\n\n### User delete\nTo let your users delete an account, link them to the `auth.user.delete` route, with the user id / `$user-\u003egetKey()` as Parameter.\nAlso if a user has permission to delete an account while viewing the `auth.user.edit` view of said account, a deletion link will be shown.\n\nThis will ask the user model for `delete` permission\n\n- If you use the `PermissionChecker` which is included in this package then adding `delete` to the `user_actions` array will grant permission to edit the users _own_ profile\n- If you wish for a more complicated behaviour, simply bring your own `PermissionChecker` for your user model. See [ipunkt/permissions](https://github.com/ipunkt/permissions) for detail\n\nThe default behaviour is to to deny deletion permission\n\n## Customization\n\n### Views\n\n- To use the packaged views but display them within your own template set the view.extends variables.\n    - view is the layout view\n    - section is the name of the section in which you want it displayed\n- To change the views entirely publish them by doing  \n    `php artisan view:publish ipunkt/auth`  \n    then edit them to your likes\n    \n### Misc Config Options\n\n#### `set_usermodel`\nDefault value: `true`\nWhen left at `true` then the AuthServiceProvider will set `auth.model` to the Model provided by this package\nSet to `false` if you wish to use your own user model.\n\n#### `set_repository`\nDefault value: `true`\nWhen left at `true` then the AuthServiceProvider will bind this packages UserRepository to `Ipunkt\\Auth\\Repositories\\RepositoryInterface`.\nThe default repository will instanciate the Model set in the config value `auth.model`.\nSet to `false` if you do not use Eloquent or want to bind your own Repository for the User creation for some reason. see\n`Change out user model` below\n\n#### `route_prefix`\nDefault value: `''`\nThis prefix is prepended to all routes set by this package. This enables you to bundle your authentication users under a\nsingle path, like `auth/`\nIf you set this, then make sure to check your `auth` filter. The default Laravel4 implementation sends the user to `/login`\nupon failing\n\n#### `set_reminder`\nDefault value: `true`\nWhen left at `true` then the AuthServiceProvider will use `auth::reminder/email` as the View for reminder emails\nSet to `false` if you wish to load a view from your app instead of customizing the package view\n\n#### `publish_user_index`\nDefault value: `false`\nWhen set to `true` then `$route_prefix/user/` will show a listing of all registered users if the `$user-\u003ecan('index', $dummyUser)`\nSee `ipunkt/permissions` for specifics about giving permissions\n\n#### `user_actions`\nDefault value: `['edit']`\nThis value configures the default PermissionChecker for the user model this package brings.\nAny action listed in this config variable is see as on a user by user base and will be allowed if the user attempts to\ndo it to his own account.\n\n#### `routes`\nDefault value: `['logout' =\u003e 'auth.login']`\nThis decides where varios actions redirect after they have successfuly finished.\nCurrently:\n- `logout` User has logged out\n\n### Extending Registration Strategies\n\nTo create your own registration strategy you will have to register an event listener to `Ipunkt.Auth.*`\n\nExample:\n\n\tclass RegistrationServiceProvider extends ServiceProvider {\n\t\tpublic function boot() {\n\t\t\tif(Config::get('auth::registration_strategy') == 'test_opt_in')\n\t\t\tEvent::listen('Ipunkt.Auth.*', 'Acme\\Listeners\\TestOptInListener');\n\t\t}\n\t\t\n\t\tpublic function register() {}\n\t}\n\n#### Events to listen for\n\n- `whenUserWasCreated(UserWasCreated $event)`\n  `UserWasCreated: UserInterface $user`\n  This is called when a User has successfully sent valid registration data.\n  It is this events responsibility to write the user to the database.\n  The default way to do this is by calling the UserStoreCommand:\n  `$this-\u003eexecute( 'Ipunkt\\Auth\\Commands\\UserStoreCommand', ['user' =\u003e $event-\u003euser] );`\n- `whenConfirmationWasAttempted(ConfirmationWasAttempted $confirmation)`\n  This is called when a user comes back from a registration link\n  \n- `whenConfirmationWasSuccessful(ConfirmationWasSuccessful $confirmation)`\n  This is called when confirmation was successful\n\n- `whenConfirmationHasFailed(ConfirmationHasFailed $confirmation)`\n  This is called when confirmation has failed\n  \nAlso see `Ipunkt\\Auth\\Listeners\\SingleOptInListener` for reference\n\n### Change user model\n\nTo use your own model set the config value `'auth.model'` to its classpath.\n\nIf your model does not inherit from eloquent you will also have to replace `'Ipunkt\\Auth\\Repositories\\RepositoryInterface'` in the Laravel IoC\n\nIf you simply want to extend the model brought by this package have your own model inherit from Eloquent and implement `Ipunkt\\Auth\\User\\UserInterface`.\n\nAll prebuild functionality is capsulated in traits and can be used directly in your new model\n\n1. `EloquentUserTrait` combines\n    * `EloquentUserInterfaceTrait` implements the laravel `UserInterface` for you (pre-4.2)\n    * `EloquentUserRemindableTrait` implements the laravel `RemindableInterface` for you (pre-4.2)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipunkt%2Fauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fipunkt%2Fauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipunkt%2Fauth/lists"}