Comments

jrglasgow’s picture

Status: Active » Needs review
StatusFileSize
new1.45 KB

It appears to me that the username constraint plugin is malformed so it doesn't know which field to save.

This patch worked for me.

Status: Needs review » Needs work
jrglasgow’s picture

updated the patch to put back a few things that were accidentally omitted

jrglasgow’s picture

Status: Needs work » Needs review
aohrvetpv’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed and looks good. Username constraint checkbox value was not getting saved because PasswordPolicyItem::admin_form_submit() expects the form element machine name ('username') to match the constraint config ID (was 'enabled', now 'username').

Applied patch and confirmed username constraint working.

Two additional comments:
1. Perhaps there should be SimpleTest functional tests that test enabling constraints as a user would do.
2. 'prime value' seems like an ambiguous name. Not clear to me what its purpose is. Best I can tell it is a machine name for the constraint, which allows a different name from the base filename of the constraint. Perhaps 'item name' or 'name' or something would be clearer? Or an explanatory comment?

erikwebb’s picture

@AohRveTPV - Since we are changing the name of the config ID, do we need an update function to change the values of existing policies?

aohrvetpv’s picture

If I understand your question correctly: There might be an unused 'enabled' element left in $config after applying this patch if the user had previously attempted to enable the username constraint. If so, it would probably be best to have an update function that removes that unused element. I will try to check.

aohrvetpv’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.61 KB

Here's a patch that adds update code. I dislike the code though because I think it is operating at the wrong level of abstraction. I think a PasswordPolicy object ought to have a save method, abstracting away the details of how it gets saved. Code like the following would seem more elegant:

  $policies = PasswordPolicy::all_policies();
  foreach ($policies as $policy) {
    unset($policy->config['username']['enabled']);
    $policy->save();
  }

Maybe there is already a way to do it like that, skipping the direct ctools calls, and I am not aware.

erikwebb’s picture

@AohRveTPV - I agree. Let's fix this issue and open a new one to refactor that method.

aohrvetpv’s picture

Sounds good. Patch in #8 adding update code is ready for review and/or commit.

aohrvetpv’s picture

Found a minor coding standards problem in patch. Will post new one soon.

aohrvetpv’s picture

Changed update function comment to the imperative per documentation standards.

deekayen’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.