[Snippet] membership_validator
#1
Posted 27 December 2007 - 11:15 AM
File Submitter: Cris D.
File Submitted: 27 Dec 2007
File Updated: 09 Sep 2009
File Category: Security
2 x Snippets by Cris D. ( member_validator1.0 and member_verifier2.0 )
Date: 2007/12/27
Uses: Allows users of an etomite site to create their own account.
Notes: the account role, permissions and document groups can be set in the snippet
All form fields are validated.
All returned language is abstracted out ready for translation.
UPDATED 2009-09-09
V2.0 membership_verifier has increased security to stop hacking attempts.
For additional security from spam accounts and robots, turn on captcha in the authenticate_visitor snippet.
Warning:
Some of this configuration requires some knowledge of document and group permissions, this can be hazardous if not set properly as you may intentionally give everyone access to everything (including the manager) in your site. Also, as this uses advanced permissions, if your site is set up with simple permissions, you may need to change some snippets to accommodate the new permissions, otherwise you may give the public access to parts of your site that are no longer protected (eg any snippets that rely on API's checkPermissions() or userLoggedIn() will return 'true' regardless of the users role).
If you are new to etomite it is recommended that you start with something easier! But if you are up for the challenge and need help, see the forums for assistance.
Contents of the attached README file:
README for the Membership Validator module
In this zip is an amended membership_validator1.1 snippet with the following changes:
//changelog for 1.1:
//changed the wrapping "<p>" to make the form validate
//added the missing phone validation code and error messages
//added the missing formChunkName so that an external chunk can be used to display the form
//improved the email_switch
//added a sample member_validator_chunk.txt file to use of an external chunk is required.
1) Enable access permissions and visitor permissions in your Etomite manager.
2) Create the new role you want your members to belong to and note the name eg 'automembers'.
3) In permissions, user groups, create a new user group eg 'downloaders'.
4) In permissions, document groups, create a new document group egg 'music'.
5) in permissions, user / document group links, create the document/group link.
6) Copy and paste the contents of the snippet membership_validator into the snippet library.
7) Copy and paste the contents for the snippet membership_verifier into the snippet library.
8) Create a new page where your members will be re-directed on clicking their email link, I suggest putting it
in the repository and 'not show in the menu' for additional security: this is the 'confirmationPage'.
9) Call the snippet membership_verifier in the page and publish it. Take note of the page id.
10) Create and publish a page where your users will create their account, call the snippet membership_validator in it.
11) configure the snippet with the following:
1) Using phpMyAdmin, locate the user role you created earlier in the etomite_user_roles table and locate the id of the role: place it in the snippet config.
2) Set the $tempExpires variable for how long users have to verify their account before the temporary records are
deleted.
3) Set the $confirmationPage page id which will be the page sent in the url in the body of the email with the
verification link.
4) Set the table name that will store your temporary records, and the email address that will appear in the "from"
fields in the validation email.
11) Configure the membership_verifier snippet with the following:
1) Set the id of the page that has your log-in script like 'authenticate_visitor' snippet - (enable captcha for added security).
2) Set the $memberGroup variable to the membergroup name that you set previously in the permissions, user group eg 'downloaders'.
3) Set the tableName to the same name that was used in the membership_validater snippet.
4) Save the snippet changes and your away.
Notes:
If you are testing this by creating test accounts, I have made it hard for surfers to create several accounts, therefore you will also have difficulty. The session username is held in the browser and automatically sent with forms, so you will get a "username and passwords don't match" error if you try to create additional test accounts. You can clear the sessions by
uncommenting
/*
unset($_SESSION['userName']);
unset($_SESSION['firstName']);
unset($_SESSION['lastName']);
unset($_SESSION['email']);
unset($_SESSION['hash']);
*/
, saving the snippet, accessing the page, re-commenting the unsets() and re-saving the snippet. Or clear your browsers sessions via browser tools.
For a live demo, see here.
Click here to download this file
#2
Posted 27 December 2007 - 02:19 PM
$prefix = "{";
$suffix = "}";
$output = preg_replace("|".$prefix."[^".$suffix."]+".$suffix."|s", "", $output);
return stripslashes($output);
EDIT: Never mind... I see that you are intentionally using those {tags}... Why, I'm not sure... The code above is still nice to keep kicking around in your bag of tricks...
#3
Posted 27 December 2007 - 04:55 PM
#4
Posted 27 December 2007 - 07:54 PM
Quote
@Cas
Quote
#5
Posted 27 December 2007 - 08:30 PM
'intro' => "<p>Registration for membership is a 3 Step process.</p>\n",and here:
'step1' => "<p><b>Step 1</b> | Step 2 | Step 3 </p>", 'step2' => "<p>Step 1 | <b>Step 2</b> | Step 3 </p>",and remove the closing tag at the end the form: line 332
$output .="</form></p>";
Edited by Cris D., 27 December 2007 - 08:32 PM.
#6
Posted 28 December 2007 - 02:29 AM
Cris D., on Dec 27 2007, 02:54 PM, said:
I use the Tigra Form Validators "phone" format for client side validation and the server side can be made to work almost the same way... I understand that most snippets are written for an intended purpose and that they can almost never be written to accomodate 100% of all situations... A good solid base from which to work is far better than starting from scratch, that is for sure... Your efforts are definitely appreciated by the membership and I'm sure that individual customizations can be plugged in as needed...
#7
Posted 28 December 2007 - 06:03 AM
I have resubmitted it with the following changes that I accidentally left off...
//changelog for 1.1:
//changed the wrapping "<p>" to make the form validate
//added the missing phone validation code and error messages
//added the missing formChunkName config and logic so that an external chunk can be used to display the form
//improved the email_switch so that it works
//added a member_validator_chunk.txt file to use as an example if an external chunk is required to create the form with.
apart from that, the zip is basically the same....
#8
Posted 14 February 2009 - 01:46 AM
Just wanted to say how much I love this snippet. I used it once ages ago on a site I never finished (got bored of the whole idea) but have just installed it on a new site I am building. It worked perfectly, your instructions were perfect, and the functionality is fantastic!
I love this snippett(s).
Thank you again!
Paul.
PS It is nowhere near as complicated to install as it looks when you first read the instructions.
#9
Posted 14 July 2009 - 12:29 PM
But we've noticed recently when perusing the users that some that look suspiciously like bots are getting into the system, which was a big surprise to me, given the 3-step process. Has anyone had this happen, or have suggestions for curbing it?
#10
Posted 18 July 2009 - 09:27 AM
Opal, on 14 July 2009 - 12:29 PM, said:
But we've noticed recently when perusing the users that some that look suspiciously like bots are getting into the system, which was a big surprise to me, given the 3-step process. Has anyone had this happen, or have suggestions for curbing it?
#11
Posted 09 September 2009 - 10:04 AM
I have had a look at how robots can create accounts, and the only way I can see them being stopped is with the use of captcha. This can be integrated into the snippet, but seeing that it is written to work with authenticate_visitor, it's easiest to enable captcha on that snippet. This will stop robots from verifying the account and therefore stopping them altogether.
Edited by Cris D., 09 September 2009 - 10:30 AM.
#12
Posted 10 September 2009 - 03:17 PM
*additions follow...
i should say that this is in a production site that has worked for over a year with the original verification/validation snippets. I also installed the newer version today on my personal site, and can't create accounts there either.
*code sample removed...
Edited by darren, 11 September 2009 - 12:00 PM.
#13
Posted 11 September 2009 - 06:55 AM
FYI I am using a regex pattern to verify that it is an MD5 hash (32 hexidecimal characters). However, as I have read in blogs, if the md5 hash generator creates a hash that leads with a "0", then it may go back to 31 characters and miss the leading zero. I have not written this check into the code and should be the only way the script fails. I thought the chances of it ocurring would be remote. Go for the latest version and you'll be ok.
Good to see someone has upgraded (I think you may be the only one Darren). You obviously care about your site and data
Edited by Cris D., 11 September 2009 - 10:14 PM.
#14
Posted 11 September 2009 - 12:31 PM
BTW i've removed the code from my post so it can stay somewhat secret if you remove it from yours...
And thanks for these snippets - they really helped me out on this site.
#15
Posted 11 September 2009 - 10:18 PM
#16
Posted 03 November 2009 - 02:59 PM
#17
Posted 12 March 2010 - 10:12 PM
trying to implement the snippet...
step 1 and 2 are ok ...but when I click on the link in the email adress I'll getting the following:
There is a registration error...this could be because:
1) you have attempted hack the site,
2) you have tried to create another account,
Please register again or contact the webmaster for assistance.
It creates the user in the DB because when I try again - it states that the username and email are already used...
can someone "pinpoint" where I've done wrong?
Edited by Wiper2007, 14 March 2010 - 12:11 AM.
#18
Posted 15 March 2010 - 06:22 AM
#19
Posted 15 March 2010 - 09:53 PM
Hmmm.. I have now completed step 1 and 2 from my home computer sending a mail to my computer at work ...
So I'll try to confirm the email link from my computer at work like a "normal" user that's trying to register...
Cris D., on 15 March 2010 - 06:22 AM, said:
Edited by Wiper2007, 15 March 2010 - 09:56 PM.
#20
Posted 16 March 2010 - 08:18 AM
Wiper2007, on 15 March 2010 - 09:53 PM, said:
Hmmm.. I have now completed step 1 and 2 from my home computer sending a mail to my computer at work ...
So I'll try to confirm the email link from my computer at work like a "normal" user that's trying to register...
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











