Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • rasb 162 posts 218 karma points
    May 14, 2009 @ 10:19
    rasb
    1

    Account Activation/Verification Email

    Hi guys,

    I have created an Umbraco Website with membership features. I have managed to create the registration form, so it will register custom data for me.

    I would like to filter fake registrations and people who regret their registration right away. I usually do this by sending people an email with a link they have to click in order to verify their registration and actually activate their account.

    Normally I solve this by setting a bit in the database to indicate Active/Inactive. But since I now just use the built in .NET login form:

    [code] [/code]

    I don't have any way to check for such a bit. I have thought of a few different scenarios to solve this:

    1) The bit already exists in Umbraco, and I just don't know where.

    2) Extend the login form, by creating a custom login form that can check for such a bit.

    3) Solve this with User Groups. Add the newly registered users to a user group called "Inactive members", and move the user to the correct user group when they click the activate link.

    I would prefer number 1. Number 2 is not that difficult, but number 3 seems to be the "cleanest" way of doing it within the Umbraco framework.

    Any thoughts or recommendations on this?

    /rasb

  • Daniel Lindstrom 454 posts 271 karma points
    May 14, 2009 @ 10:24
    Daniel Lindstrom
    0

    On an umbraco v3 site have solved it with groups, exactly as you described it in 3. Was really simple.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    May 14, 2009 @ 10:29
    Dirk De Grave
    0

    Hi,

    [quote]Normally I solve this by setting a bit in the database to indicate Active/Inactive. But since I now just use the built in .NET login form
    [/quote]

    You still can, check the bit in the LoggingOn event, and cancel logging in if member not yet active.
    using the login, you know who's logging on, get the member associated with the provided login credentials and check that active property using member.getProperty("IsActive").Value

    Your third option is also viable, but still requires 'code changes' for the login control as in that case you'd need to check whether user is in correct group

    Bottom line: I'd go for the extra bit (IsActive property on the member type), check active property upon login (LoggingOn event - cancel if not yet active), use activation link to set active property

    If you don't want to use the Logging_X events on the login control, consider overriding the ValidateUser behaviour (Tim has done a great small tutorial on that); it implies building a custom membership provider tho...

    Link: http://www.nibble.be/?p=66

    Cheers,
    /Dirk

  • rasb 162 posts 218 karma points
    May 14, 2009 @ 11:47
    rasb
    1

    Hi Dirk,

    Thank you for your swift reply. I decided to give it a quick try, and it turned out to be very simple indeed.

    I implemented the custom membership provider and then added two new properties to the member type;

    - Active (as described by Nibble)
    - ActivationCode (one I added, which was a textstring that contains a Guid)

    I have included the code I have created, if anyone wants to have a look. It might help others. There is some extra code in addition to the code supplied by Nibble. The code was written in a hurry, so the response messages could be done prettier, but it works.

    At registration time I generate a new guid that I put in the ActivationCode property.

    [code]MemberType demoMemberType = MemberType.GetByAlias(this.MemberTypeAlias);
    MemberGroup addToMemberGroup = MemberGroup.GetByName(this.MemberGroupName);
    Member newMember = Member.MakeNew(txtName.Text, demoMemberType, new umbraco.BusinessLogic.User(0));

    newMember.Email = txtEmail.Text;
    newMember.Password = txtPassword.Text;
    newMember.LoginName = txtUsername.Text;
    newMember.AddGroup(addToMemberGroup.Id);

    Guid activationCode = Guid.NewGuid();

    newMember.getProperty("active").Value = false;
    newMember.getProperty("activationCode").Value = activationCode.ToString();

    newMember.Save();[/code]

    Then I send an email to the newly created member with a link that is formatted like this:

    [code]/verify.aspx?u=

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    May 14, 2009 @ 13:16
    Richard Soeteman
    0

    Hi,

    Did you check this article allready seems to me that it should do the trick?

    Cheers,

    Richard

  • Erik Ernst 70 posts 90 karma points
    Mar 26, 2010 @ 11:24
    Erik Ernst
    0

    The above worked perfectly. Thank you very much, it was just what I needed!

Please Sign in or register to post replies

Write your reply to:

Draft