{"id":20779227,"url":"https://github.com/bolt/users","last_synced_at":"2025-04-30T19:41:20.241Z","repository":{"id":43099462,"uuid":"277838971","full_name":"bolt/users","owner":"bolt","description":"Bolt users extension.","archived":false,"fork":false,"pushed_at":"2022-09-08T14:39:44.000Z","size":59,"stargazers_count":8,"open_issues_count":9,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-16T06:09:32.804Z","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/bolt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-07T14:27:50.000Z","updated_at":"2022-06-20T09:10:59.000Z","dependencies_parsed_at":"2022-09-13T06:52:03.091Z","dependency_job_id":null,"html_url":"https://github.com/bolt/users","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bolt%2Fusers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bolt%2Fusers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bolt%2Fusers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bolt%2Fusers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bolt","download_url":"https://codeload.github.com/bolt/users/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251770963,"owners_count":21641180,"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-17T13:26:41.207Z","updated_at":"2025-04-30T19:41:20.202Z","avatar_url":"https://github.com/bolt.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bolt Users Extension\n\nThe Bolt users extension allows you to add front-end users to your website.\n\nHere is a list of things that the extension allows:\n\n- Define groups of users, allow them to register and login\n- Limit ContentTypes (pages) to be visible only by users belonging to a certain group\n- Define user fields and allow them to edit their own profile\n\n## Installation\n\nTo install this extension, simply run the following terminal command from your root folder:\n\n```\ncomposer require bolt/users\n```\n\n## Basic usage\n\nTo limit a ContentType to a specific group of users, say `ROLE_MEMBER`, do the following:\n\n1. Define your user group in `config/extensions/bolt-usersextension.yaml`:\n\n```yaml\ngroups:\n  ROLE_MEMBER:\n    redirect_on_register: homepage # Provide either a route name, or a URL\n    redirect_on_login: / # Provide either a route name, or a URL\n    initial_status: enabled # Once a user registers, he/she is automatically allowed to login\n```\n\n2. Limit the access to a certain ContentType, e.g. `entries` to that user group in\n`config/contenttypes.yaml`:\n\n```yaml\nentries:\n    name: Entries\n    singular_name: Entry\n    fields:\n        # ... normal ContentType definition\n    allow_for_groups: [ 'ROLE_MEMBER', 'ROLE_ADMIN' ]\n```\n\nNote: The `allow_for_groups` option is used to limit access to the ContentType (listing\nas well as record pages). It will only allow users who are logged in and have the\ncorrect permission to access those pages. Not even admins will be allowed to view\nthose pages, hence why we add the `ROLE_ADMIN` group to ensure admins have view rights\ntoo.\n\n3. Allow users to register and to login\n\nThe extension allows you to include a registration form on any twig template.\nTo add a registration form, just add the following to your twig file:\n\n```twig\n    {{ registration_form(group='ROLE_MEMBER') }}\n```\n\nThis line below will render a registration form with username, password and email\nfields for the user to fill in. You must always specify the user group to which\nthis form applies (in this case, `ROLE_MEMBER`). Users who register with that group will\nautomatically receive access rights to ContentTypes limited to that group.\n\nCurrently, the `registration_form` function accepts the following options:\n\n| Option name   | Description   | Required / optional  |\n| ------------- |:-------------:| -----:|\n| group         | The group for the registering user. Must match a group defined in the extension config. | required |\n| withlabels    | If true, the `label` fields for each input will be included. Default is true.      |   optional |\n| labels | An array used to override default labels. The key is the field name, e.g. `username` and the value is the label to be used. | optional |\n\nTo render the login form, use the following:\n\n```twig\n    {{ login_form() }}\n```\n\nThe login function does not specify the group. The extension will try to authenticate the \nuser with his/her credentials, and assign the correct group to that user. The `login_form`\nfunction accepts two optional arguments, `withlabels` and `labels` which work the same way\nas they do for the `registration_form` function.\n\n## User profiles\n\nSometimes, you want to do more with users than simply restrict access to certain pages.\nThe extension allows you to define custom user fields by linking a ContentType to a\nuser group.\n\nFor example, to define a date of birth to our 'ROLE_MEMBER' group, we would do the following:\n\n1. Define a `members` ContentType in `config/contenttypes.ymal` that will be used to store information about users.\n\n```yaml\nmembers:\n    name: Members\n    singular_name: Member\n    title_format: \"{author.username}\"\n    fields:\n      dob:\n        type: date\n    viewless: true\n```\n\nThen, edit the extension config in `config/bolt-usersextension.yaml`:\n\n```yaml\ngroups:\n  ROLE_MEMBER:\n    redirect_on_register: homepage\n    redirect_on_login: /\n    initial_status: enabled\n    contenttype: members # Link the 'members' ContentType to the 'ROLE_MEMBER' group.\n```\n\nNow, users belonging to the `ROLE_MEMBER` group will be able to access their profile\nat `/profile`. You can customize the appearance of this page by customizing the\nrecord template for the members ContentType.\n\n2. Optionally, you may wish to allow members to edit their profiles. To do this, add\nthe following to the config:\n\n```yaml\ngroups:\n  ROLE_MEMBER:\n    redirect_on_register: homepage\n    redirect_on_login: /\n    initial_status: enabled\n    contenttype: members\n    allow_profile_edit: true # If true, members will be able to edit their profiels on /profile/edit . You must specify the edit template below\n    profile_edit_template: 'edit_profile.twig'\n\n```\n\nIn this case, the `edit_profile.twig` file, located in the `public/theme/your-theme/` directory,\nmay contain any regular twig template. Here is a basic example of the edit form that you\ncan include:\n\n```twig\n\u003cform method=\"post\"\u003e\n    {% for field in record.fields %}\n        \u003clabel for=\"fields[{{ field.name }}]\"\u003e\u003c/label\u003e\n        {% if field.type === 'text' %}\n            \u003cinput type=\"text\" name=\"fields[{{ field.name }}]\" value=\"{{ field.parsedValue }}\" /\u003e\n        {% elseif field.type === 'textarea' %}\n            \u003ctextarea name=\"fields[{{ field.name }}]\"\u003e{{ field.parsedValue }}\u003c/textarea\u003e\n        {% elseif field.type === 'checkbox' %}\n            \u003cinput type=\"checkbox\" name=\"fields[{{ field.name}}]\" value=\"{{ field.parsedValue }}\" /\u003e\n        {% elseif field.type === 'date' %}\n            \u003cinput type=\"date\" name=\"fields[{{ field.name }}]\" value=\"{{ field.parsedValue }}\" /\u003e\n        {% endif %}\n    {% endfor %}\n\n    \u003c!-- The input fields below are required for Bolt to process the form. Do not change them --\u003e\n    \u003cinput type=\"hidden\" name=\"_csrf_token\" value=\"{{ csrf_token('editrecord') }}\"\u003e\n    \u003cinput type=\"hidden\" name=\"_edit_locale\" value=\"{{ user.locale }}\"\u003e\n    \u003cinput type=\"hidden\" name=\"status\" value=\"published\"\u003e\n    \u003cinput type=\"submit\" value=\"save\"\u003e\n\u003c/form\u003e\n```\n\n## Customizing the register and login form appearance\n\nIf the customization options available in the `registration_form` and `login_form`\nfunctions are not enough, you may wish to use the following functions:\n\nFor registration:\n\n| Function      | Description   |\n| ------------- |:-------------:|\n| `registration_form_username`      | Renders the username field |\n| `registration_form_password`      | Renders the password field |\n| `registration_form_email`         | Renders the email field    |\n| `registration_form_group`         | Renders a hidden field for the user's group. |\n| `registration_form_csrf`          | Renders a hidden field that contains a CSRF token. |\n| `registration_form_submit`        | Renders the submit button |\n\n---\n\nFor logging in:\n\n| Function      | Description   |\n| ------------- |:-------------:|\n| `login_form_username`      | Renders the username field |\n| `login_form_password`      | Renders the password field |\n| `login_form_csrf`          | Renders a hidden field that contains a CSRF token. |\n| `login_form_submit`        | Renders the submit button |\n| `login_redirect_url`       | redirect to \"/\" after submit |\n\n\nEach field function above takes an optional `withlabel` argument and the `labels` argument\nthat is also used by `registration_form`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbolt%2Fusers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbolt%2Fusers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbolt%2Fusers/lists"}