Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simple_account_policy
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
simple_account_policy
Commits
be2e196e
Commit
be2e196e
authored
1 year ago
by
Kris Booghmans
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3452393
: Disable username changes
parent
0a140685
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!11
Resolve #3452393 "Disable username changes"
Pipeline
#191518
passed with warnings
1 year ago
Stage: build
Stage: validate
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
simple_account_policy.module
+5
-4
5 additions, 4 deletions
simple_account_policy.module
with
5 additions
and
4 deletions
simple_account_policy.module
+
5
−
4
View file @
be2e196e
...
...
@@ -103,6 +103,11 @@ function simple_account_policy_form_user_form_alter(&$form, FormStateInterface $
/** @var \Drupal\simple_account_policy\AccountPolicyInterface $accountPolicy */
$accountPolicy
=
\Drupal
::
service
(
'simple_account_policy'
);
$user_prevent_changes
=
(
$accountPolicy
->
getConfiguration
()
->
get
(
'username_prevent_changes'
)
??
FALSE
);
if
(
$accountPolicy
->
applyPolicy
(
$currentUser
)
&&
$user_prevent_changes
)
{
$form
[
'account'
][
'name'
][
'#disabled'
]
=
TRUE
;
}
// We need user input here, since fields are not in values (yet).
$input
=
$form_state
->
getUserInput
();
$data
=
[
...
...
@@ -112,10 +117,6 @@ function simple_account_policy_form_user_form_alter(&$form, FormStateInterface $
$errors
=
empty
(
$pass
)
?
[]
:
$accountPolicy
->
validate
(
$currentUser
,
$data
);
$policy
=
$accountPolicy
->
policy
(
$currentUser
,
$errors
);
if
(
$accountPolicy
->
getConfiguration
()
->
get
(
'username_prevent_changes'
)
??
FALSE
)
{
$form
[
'account'
][
'name'
][
'#disabled'
]
=
TRUE
;
}
if
(
!
empty
(
$policy
[
'mail'
]))
{
$form
[
'account'
][
'mail'
][
'#description'
]
=
$policy
[
'mail'
];
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment