Copied to clipboard

Flag this post as spam?

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


  • Shaun Brown 6 posts 22 karma points
    Jul 22, 2009 @ 12:34
    Shaun Brown
    0

    How to encrypt passwords with umbraco

    Hello,

    I've come across a problem, it could be due to my limited knowledge of umbraco (fairly new to it).  However, what I'm trying to achieve is using the functionality of the umbraco password hash encryption.

    The reason behind this is so I can create a custom Login/register form, but for me to match/insert the correct values in the umbraco tables I need to hash/encrypt the password the same way it has been done already.

    Now I've managed to achieve adding the user in find.  But it's for the password hash/encryption alone I need to use.  For example:

    Also currently importing the following in this custom login/register class:

    [code]

    using umbraco.cms.businesslogic.member;
    using umbraco.cms.businesslogic.propertytype;

    [/code]

    [code]

            // umbraco way of doing things =]
            public bool AddUmbracoMember(string pEmail, string pName, string pPassword, string[] pData)
            {
                bool addedUser = true;

                if (Member.GetMemberFromEmail(pEmail) == null)
                {
                    MemberType memberType = new MemberType(1032);

                    Member newUser = Member.MakeNew(pName, memberType, new umbraco.BusinessLogic.User(0));
                    newUser.Email = pEmail;
                    newUser.Password = pPassword;
                    newUser.LoginName = pName;
                    newUser.Save();

                    AddNewUserData(pEmail, pData);
                }
                else
                {
                    addedUser = false;
                }

                return addedUser;
            }

    [/code]

    But of course using the

    [code]

                    newUser.Password = pPassword;

    [/code]

    on its own doesn't work as it's only accepting values and not returning.  Let me know if you've got any solutions for this problem of mine.

     

    Thanks,

    Shaun

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 22, 2009 @ 13:15
    Dirk De Grave
    0

    Hi,

    If you need to encrypt passwords, you should take a look at how it's done in umbraco (as you'd like to add members in the umbraco member table, so encryption should be identical).

    Password encryption is used in the umbraco membership provider implementation, so there's where you should take a peek. 

    On a sidenote, I don't really understand why you're doing your own AddUmbracoMember() function? If you need to create your own login/registration process, you should roll your own membership provider implementation and replace the default umbraco one.

    I might not have completely understood the question though.

     

    Cheers,

    /Dirk

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Jul 22, 2009 @ 14:56
    Thomas Höhler
    0

    Use the umbraco.providers.UsersMembershipProvider.EncodePassword() funtion.

    Thomas

Please Sign in or register to post replies

Write your reply to:

Draft