PROJECT PAGE
https://drupal.org/sandbox/ChristianAdamski/2101589
GIT REPOSITORY
git clone http://git.drupal.org/sandbox/ChristianAdamski/2101589.git email_field_verification
MOTIVATION
About a year ago, we had a scenario, were people would need to verify their membership with certain organizations by registering with email-addresses belonging to those organisations. Imagine somebody proving to work for Google by receiving a mail to his xy@google.com with a verification link.
This module sends out such a link.
More complicated are probably two other questions:
1.) What to do when the link is actually clicked?
- this module offers a hook so you can do what seems practical
- I could add functions to publish/activate nodes/users in case that the entity in question is either, good idea?
2.) What to do if the link is not clicked?
This module offers to
- do nothing
- react to aforementioned invoked hook yourself
- timeout after a set period, which then forbids verification
- allow to resend link
- delete entity
- empty email field
This seems a fairly common scenario, yet I did not manage to find something similar in contrib. At least not a year ago. Maybe I'm wrong?
HOW TO TEST
Create an Email field somewhere.
Check the verification option in the field settings.
Choose some options.
Fill the field.
A mail should be generated.
You can now either click the link to confirm, or wait after the period to check the timeout behavior.
DESCRIPTION
------------
This module extends the email field. It adds the option to sent out a mail with a verification link and the process the link when clicked.
Additionally it offers behavior, if a link is not confirmed within a given time.
INSTALLATION
-------------
1. Place the entire email_field_verification directory into your Drupal sites/all/modules/
directory.
2. Enable the email field verification module by navigating to:
administer > modules
3. If using this module with entities other than 'node' and 'user', you
will need the "Entity API (entity)" module.
Dependencies
-------------
* Email (email / core)
* (optional) Entity API (entity)
Features
---------
* sending verification link
* handling link
* handling timeout
* offering resending link
Reviews of other projects
* https://drupal.org/node/2107725#comment-7946603
* https://drupal.org/node/2107661#comment-7946629
* https://drupal.org/node/2107005#comment-7946649
Author
-------
Christian Adamski
ChristianAdamski@drupal.org
Comments
Comment #0.0
christianadamski commentedReviewing this description
Comment #0.1
christianadamski commentedFurther improving desc
Comment #0.2
christianadamski commentedFixed repo link
Comment #0.3
christianadamski commentedAdded missing detail
Comment #1
PA robot commentedThere are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxChristianAdamski21015...
We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #1.0
PA robot commentedMore details
Comment #2
christianadamski commentedOk, reworked some parts.
Pareview is happy now.
Comment #3
christianadamski commentedGuess I can change the status back to review for now.
Comment #3.0
christianadamski commentedAdded How to test
Comment #3.1
christianadamski commentedStarting Review Bonus
Comment #3.2
christianadamski commentedReview #2
Comment #4
christianadamski commentedHoping to find somebody to review.
Comment #5
coredumperror commentedYour module depends on the Email module, but your documentation doesn't specifically state that. Upon closer reading, I realize that I should have inferred the need to install the Email module, but being explicit about deoendecies is very important.
Upon performing a test, I got the email, but clicking the link lead to an error page saying "The mail address could not be confirmed." Debugging showed that the $hash parameter for
_email_field_verification_link_confirm()was always an empty string. This is becauseemail_field_verification_menu()defined this callback's "page arguments" value as 3, when it should have been 2. The "page arguments" value is super confusing to me, too.Fixing that bug led to the successful "Your mail address has been confirmed" page. Yay!
So then I tried to force a late confirmation by waiting too long (I also added a 1-minute timeout option, for convenience). I got the "It took you too long to confirm this mail address" message, which is good... but I set the option to "Delete entity/content" as the timeout response, and I unfortunately got these errors as well:
Warning: Missing argument 2 for entity_delete(), called in /drupal_testing/sites/all/modules/email_field_verification/email_field_verification.module on line 604 and defined in entity_delete() (line 268 of /drupal_testing/sites/all/modules/entity/entity.module).
Notice: Undefined variable: id in entity_delete() (line 269 of /drupal_testing/sites/all/modules/entity/entity.module).
Warning: class_implements() [function.class-implements]: object or string expected in entity_delete_multiple() (line 290 of /drupal_testing/sites/all/modules/entity/entity.module).
Warning: in_array() expects parameter 2 to be array, boolean given in entity_delete_multiple() (line 290 of /drupal_testing/sites/all/modules/entity/entity.module).
That's two major functionality-breaking bugs. I'm runnign this on an almost totally clean Drupal install, so my best guess is that your testing setup may have been relying on modules you didn't know about, or your edits to satisfy PAReview may have broken something. Please repair these errors so that your module can run on a clean Drupal site, and I'll be glad to continue my review.
Comment #6
christianadamski commentedOh dear. Your guess is correct, these are all the things I "cleaned up" to prepare the module last week.
I will fix this stuff and try to add some tests to not let it happen again.
But foremost: Thanks alot coredumperror for taking the time to review :)
Comment #6.0
christianadamski commented#3 Review
Comment #7
R2-D8 commentedGood catch. Wonder nobody came up with this idea yet.
Made a quick review. Getting errors when calling verification links:
Additionally I'm wondering about the flow:
I'll have a look at your sandbox again. So far good work, hope to see this released soon.
Comment #8
christianadamski commentedAdded changes from Readme
Comment #9
christianadamski commentedOkay, the mentioned problems should be fixed. Module should work fine now.
To verify this, I added a basic test. Run it with Admin -> Development -> Testing.
Please review :)
To coredumperror & R2-D8: Your input is appreciated and right now I am figuring out, how to handle your ideas best.
Comment #10
christianadamski commentedForgot to change status
Comment #11
xiukun.zhou commentedadd hook_uninstall to email_field_verification.install and remove email_field_verification_data table
Comment #12
christianadamski commented@xiukun.zhou
Quoting from hook_uninstall - "Database tables defined by hook_schema() will be removed automatically."
I just tested with my module, it works.
Comment #13
christianadamski commentedComment #14
klausiReview of the 7.x-1.x branch:
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.
manual review:
Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.
Comment #15
christianadamski commentedHello klausi,
THANKS A LOT! This must have taken some time! I learned a lot going through your comments and I hope a got it all fixed.
email_field_verification_schema(): The comment what the "status" columns can mean should actually be in a description property of the column, so that this info is available on the database table directly (for example when looking at it with Phpmyadmin).Changed.
_email_field_verification_get_settings_defaults(): doc block is wrong? This should describe what your function does, at least briefly. Same at _email_field_verification_delete(), please do not add useless doc blocks.Fixed/Added.
"'#description' => 'Should the email require verification by link sent to it.',": all user facing text must run through t() for translation, please check all your strings.Fixed. Think I got all strings.
email_field_verification_entity_delete(): $entity_type is missing in the query, so you could delete multiple records from other entity types, which can lead to unintended data loss.Added.
email_field_verification_permission(): why is the first permission marked as "'restrict access' => TRUE,"? Please add a comment. Does this permission allow a user to take over the site?Removed.
email_field_verification_field_update_instance(): the column instance_id does not exist on the table email_field_verification_data, so this will throw database exceptions?I see your point, but I don't really see, what to split up right now.
email_field_verification_cron(): this will not scale. As soon as you have more than a couple of hundreds databse rows cron will run into timeouts. I think you should construct a select query that only picks entries where the timestamp has been exceeded, that would reduce the number of entries, correct?Added an additional column "timeout" and now added that condition + "status" column. This should scale a lot better.
"$entity_info = entity_get_info($entity->type);": this will only work for nodes, other entities might have the bundle in a different property. use entity_extract_ids() instead.Changed everywhere.
_email_field_verification_resend(): this is vulnerable to CSRF exploits. You are performing a state changing write operation here without a confirmation form or checking a security token. See http://epiqo.com/en/all-your-pants-are-danger-csrf-explained . And please don't remove the security tag, we keep that for statistics and to show examples of security problems.Added drupal_get/valid_token.
Comment #16
klausimanual review:
But otherwise looks RTBC to me.
Assigning to mitchell as he might have time to take a final look at this.
Comment #17
christianadamski commentedConvience on my side, to quickly identify user-facing strings. If this is an issue, I can revert this of course.
I don't feel certain about splitting the file up right now. If it does get accepted and actually used, I might extend it and split it up, but right now I think it is better in one file.
But it is, isn't it? Am I missing something? Is there a quick way to check this?
_email_field_verification_resend(): does the token verification work? Shouldn't you call drupal_get_token with the same $value as drupal_valid_token()?Oh dear, missed that on last minute changes. Issue is: tokens in DrupalWebTestCase seem to fail due to #1555862. I don't know how to work around that and it causes my tests to fail unnecessary.
_email_field_verification_resend(): instead of all the empty() checks in the beginning you could just specify the route as email/verification/resend/ajax/%/%/%/%/%/% or similar in hook_menu()? Then you can be sure that the arguments are always there, otherwise Drupal core will return a 404 for you.Done.
Comment #18
mitchell commentedSorry, can't help here. Good luck, all.
Comment #19
klausiSomehow this fell of my radar, sorry. No objections for more than a week, so ...
Thanks for your contribution, ChristianAdamski!
I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks to the dedicated reviewer(s) as well
Comment #20
christianadamski commentedThank you! :)
woop woop