Problem/Motivation
Currently, we only have basic validation such as username beginning or ending with a space, or username too long. There is no logic to check if user actually exist on Drupal.org or not.
Steps to reproduce
Enter a wrong username and field would still save the data.
Proposed resolution
We can add another validation, which will verify the user data from this link https://www.drupal.org/api-d7/user.json?name=gaurav.kapoor and then based on information returned by the API we can show appropriate error message.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | log_error.txt | 7.65 KB | andregp |
Issue fork do_username-3255230
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
hussainwebIt's a good idea. But I would like to make this conditional. How about adding a field setting that lets someone enable/disable this validation?
Comment #3
andregp commentedI'll try to work on this.
@hussainweb, is there anything else you'd like to point out or request?
Comment #4
andregp commentedI don't know for which reason, but as soon as I try to add a new field of type "Drupal.org username" my site crashes.
Comment #5
hussainwebInteresting @andregp, can you post any recent log messages? It may be a good idea to do this in a new issue.
Comment #6
andregp commentedThese are the messages on the browser console.
I get this error when I create a new content type, add a 'Drupal.org username' field and select 'save and continue'.
It's strange because the fields are somehow added to the new content type (if I go back in the browser and refresh the page the field appears listed there), but as soon as I try to access or create a new node of this content type I get the same error page.
It can be a new issue or I just did something wrong during this module installation.
Comment #7
andregp commentedAlso when I try to uninstall the module, even after deleting all related content, I get this error (see screenshot) which prevents me from trying to uninstalling/reinstalling the module.
Comment #8
hussainweb@andregp, can you share errors from the dblog instead of the console. You should find it at
/admin/reports/dblogor from the toolbar "Reports" -> "Recent Log messages".And the error is as designed. You need to manually delete the field before uninstalling the module. This is the behaviour with all modules that provide a field type.
Comment #9
andregp commentedOh okay, so here is attached a log error message from /admin/reports/dblog (thanks for the tip).
Also I manually deleted all fields before uninstalling the module, but I haven't added any field called 'user.field_do_username' and thus wasn't able to delete it. The only place I could find it on the code was on the yml files that came with the project (under config/install/).
Comment #10
gaurav.kapoor commented@andregp You will have to run composer and make sure all the dependencies of the module are installed in your setup.
Comment #13
sahal_va commentedI have added a new field setting to enable validation which will appear as a checkbox in the field's storage settings form.
Added a new constraint to validate the username from the API if the validate setting is ON.
Please review and let me know if any changes are needed.
Comment #15
hussainwebI tested this and it works well. The problem is that on existing sites, the option is turned on by default without notice. This means there is a behavior change because of this patch. Since the module is currently alpha, this is okay.
Comment #16
hussainweb