{% extends "_layouts/cp" %} {% if CraftEdition == CraftPro and currentUser.can('editUsers') %} {% set crumbs = [ { label: "Users"|t('app'), url: url('users') }, ] %} {% endif %} {% import "_includes/forms" as forms %} {% do view.registerAssetBundle("craft\\web\\assets\\fileupload\\FileUploadAsset") %} {% do view.setIsDeltaRegistrationActive(true) %} {% set requireEmailVerification = craft.app.projectConfig.get('users.requireEmailVerification') ?? true %} {% set canAdministrateUsers = currentUser.can('administrateUsers') %} {% if craft.app.request.isPost %} {% set currentGroupIds = craft.app.request.getBodyParam('groups') ?: [] %} {% else %} {% set currentGroupIds = user.getGroups()|column('id') %} {% endif %} {% set hiddenInputs %} {{ csrfInput() }} {% if not isNewUser -%} {{ hiddenInput('userId', user.id) }} {%- endif %} {% endset %} {% hook "cp.users.edit" %} {% block actionButton %} {% if not currentUser.can('registerUsers') or CraftEdition != CraftPro %} {% else %}
{% endif %} {% endblock %} {% block content %} {% set formAttributes = { id: 'userform', method: 'post', 'accept-charset': 'UTF-8', data: { saveshortcut: true, 'saveshortcut-redirect': (user.getIsCurrent() ? 'myaccount' : (CraftEdition == CraftPro and currentUser.can('editUsers') ? 'users/{id}' : 'dashboard'))|hash, 'saveshortcut-scroll': true, 'confirm-unload': true, delta: true, }, } %}
{{ actionInput('users/save-user') }} {{ redirectInput(CraftEdition == CraftPro and currentUser.can('editUsers') ? 'users' : 'dashboard') }} {{ hiddenInputs }}
{% include "users/_accountfields" %} {% if not isNewUser and showPhotoField %} {{ forms.field({ label: "Photo"|t('app'), id: 'photo' }, include('users/_photo', {user: user}, with_context = false)) }} {% endif %} {% if isNewUser %}
{{ forms.textField({ label: "Email"|t('app'), id: 'email', name: 'email', value: user.email, required: true, type: 'email', errors: user.getErrors('email')|merge(user.getErrors('unverifiedEmail')), inputAttributes: { data: {lpignore: 'true'}, }, }) }} {{ forms.checkboxField({ label: 'Send an activation email now'|t('app'), name: 'sendActivationEmail', checked: true }) }} {% elseif user.getIsCurrent() or canAdministrateUsers %}
{{ forms.textField({ label: "Email"|t('app'), warning: requireEmailVerification and not canAdministrateUsers ? 'New email addresses must be verified before taking effect.'|t('app'), id: 'email', name: 'email', value: user.email, required: true, type: 'email', errors: user.getErrors('email')|merge(user.getErrors('unverifiedEmail')), inputAttributes: { data: {lpignore: 'true'}, }, }) }} {% if user.getIsCurrent() %} {{ forms.passwordField({ label: "New Password"|t('app'), id: 'newPassword', name: 'newPassword', autocomplete: 'new-password', errors: user.getErrors('newPassword'), inputAttributes: { data: { lpignore: user.getIsCurrent() ? false : 'true', }|filter, }, }) }} {% js %} new Craft.PasswordInput('#newPassword'); {% endjs %} {% endif %} {% if canAdministrateUsers %} {{ forms.checkboxField({ label: "Require a password reset on next login"|t('app'), name: 'passwordResetRequired', checked: user.passwordResetRequired }) }} {% endif %} {% endif %}
{{ fieldsHtml|raw }} {% if CraftEdition == CraftPro and (currentUser.can('assignUserGroups') or currentUser.can('assignUserPermissions')) %} {% endif %} {% if user.getIsCurrent() %} {% endif %} {# Give plugins a chance to add other things here #} {% hook "cp.users.edit.content" %}
{% endblock %} {% block details %} {% if not isNewUser %} {% if CraftEdition == CraftPro %}
{{ hiddenInputs }}
{{ "Status"|t('app') }}
{{ statusLabel }}
{% if actions|length %}
{% endif %}
{% if user.locked and craft.app.config.general.cooldownDuration and user.remainingCooldownTime %}
{{ "Cooldown Time Remaining"|t('app') }}

{{ user.remainingCooldownTime|duration }}

{% endif %}
{{ "Registered at"|t('app') }}

{{ user.dateCreated|datetime('short') }}

{% if user.getStatus() != 'pending' %}
{{ "Last login"|t('app') }}

{% if user.lastLoginDate %}{{ user.lastLoginDate|datetime('short') }}{% else %}{{ "Never"|t('app') }}{% endif %}

{% if user.getStatus() == 'locked' %}
{{ "Last login fail"|t('app') }}

{% if user.lastInvalidLoginDate %}{{ user.lastInvalidLoginDate|datetime('short') }}{% endif %}

{{ "Login fail count"|t('app') }}

{{ user.invalidLoginCount }}

{% endif %} {% endif %}
{% endif %} {% endif %} {# Give plugins a chance to add other stuff here #} {% hook "cp.users.edit.details" %} {% endblock %} {% js %} {% if user.getIsCurrent() %} var changeSidebarPicture = true; {% else %} var changeSidebarPicture = false; {% endif %} new Craft.ElevatedSessionForm('#userform', [ {% if not isNewUser %} '#email', '#newPassword', {% endif %} '#admin:not(:checked)', '#user-groups input[type="checkbox"]:not(:checked)', '#permissions input[type="checkbox"]:not(:checked)' ]); {% endjs %}