Copied to clipboard

Flag this post as spam?

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


  • Patrick Irvin 3 posts 23 karma points
    Mar 09, 2010 @ 23:37
    Patrick Irvin
    0

    Paid Membership - access controlled site

    I am building a site which will sell restricted content for paying members with only a few sections open to general public.  I have looked at Joomla/Community Builder/CBSubs as a solution but would prefer to build in Umbraco and .net.

     

    Can anyone point me in right direction to learn about setting up payment/registration process similar to what Umbraco uses for controlling access to Videos?

     

    Thanks for your help,

     

    Patrick

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Mar 10, 2010 @ 00:16
    Aaron Powell
    0

    Umbraco nodes (pages) have Public Access which is controlled from within the CMS. Changing this will determine who can and who can't access the page.

    This will then go via standard ASP.NET Membership functions to achieve what you require. If you have different Member Groups (aka ASP.NET User Roles) you can choose which groups can access a page (ie - PaidType1) and which can't.

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Mar 10, 2010 @ 02:27
    Nik Wahlberg
    0

    Hi Patric, you should use the 'Public Access' functionality available in the right-click menu on the desired nodes (presumably level 1 parent nodes depending on how your site is set up). Then, Umbraco support native .Net membership functionality so you can throw in a asp:login, asp:loginView, etc. and work with the providers sepcified in your Web.config

    <!-- Membership Provider -->
        <membership defaultProvider="UmbracoMembershipProvider" userIsOnlineTimeWindow="15">
          <providers>
            <clear />
            <add name="UmbracoMembershipProvider" type="umbraco.providers.members.UmbracoMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false" defaultMemberTypeAlias="Another Type" passwordFormat="Hashed" />
            <add name="UsersMembershipProvider" type="umbraco.providers.UsersMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false" passwordFormat="Hashed" />
          </providers>
        </membership>

    You can certainly create your own providers here which is probably what you are going to want to do so that you can check whether an account is paid (current) and if not you can stop the login process  and throw a user error. Something like this would do the trick:

    using System;
    using System.Text;
    
    namespace YourNameSpaceForTheProject
    {
        public class CustomMembershipProvider : umbraco.providers.members.UmbracoMembershipProvider
        {
            public override bool ValidateUser(string username, string password)
            {
                string passwordEndoded = EncodePassword(password);
                umbraco.cms.businesslogic.member.Member m = umbraco.cms.businesslogic.member.Member.GetMemberFromLoginNameAndPassword(username, passwordEndoded);
    
                if (m == null)
                {
                    return false;
                }
    
                try
                {
                    // check to make sure the isactive property of the member is set to 1 
                    // (this tells us if they have gone through the payment process of have been manually set to active)
                    if (m.getProperty("isActive").Value.ToString() == "1")
                    {
                        return true;
                    }
                    else
                    {
                        Literal failLit = (Literal)YourNameSpaceForTheProject.FindControl("FailureText");
                        failLit.Text = "Your account is not active. Please call your acount rep.";
                        return false;
                    }
                }
                catch
                {
                    return false;
                }
    
                return (m != null);
            }
    
            private string EncryptPassword(string password)
            {
                System.Security.Cryptography.HMACSHA1 hash = new System.Security.Cryptography.HMACSHA1();
                hash.Key = Encoding.Unicode.GetBytes(password);
                string retVal = Convert.ToBase64String(hash.ComputeHash(Encoding.Unicode.GetBytes(password)));
    
                return retVal;
            }
        }
    }
    

    Of course, this assumes that you have setup a Member Type with at least the property isActive. This article talks about the member API and should be useful if you have not worked with members in the past. There are a lot of posts on here as well that deals with membership. Let us know if you have additional questions. 

    Cheers,
    Nik

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Mar 10, 2010 @ 02:29
    Nik Wahlberg
    0

    In fact, here is a short article that was written a while back. 

    http://our.umbraco.org/wiki/how-tos/membership-providers/check-if-user-is-active-before-logging-in

    -- Nik

  • Patrick Irvin 3 posts 23 karma points
    Mar 10, 2010 @ 15:17
    Patrick Irvin
    0

    Great!  Thanks for the pointers!

  • Petr Snobelt 923 posts 1535 karma points
    Mar 10, 2010 @ 16:08
    Petr Snobelt
    0

    Or you can look at ClientArea in Projects section

    Petr

  • Erdöl Biramen 1 post 71 karma points
    Dec 16, 2016 @ 22:46
    Erdöl Biramen
    0

    Hi,

    I would like to create a site where users will pay to access certain pages.

    Thereby I would like to offer users several options:

    .) time-limited subscriptions giving access to a certain number of pages in one single section (the selection will be done by the user). e.g. any 3 pages or any 5 pages, all in one single section, for the duration of a month

    .) time-limited subscriptions giving access to a certain number of pages in ANY section (the selection will be done by the user). e.g. any 3 pages or any 5 pages from any section for the duration of a month

    .) Buying credits which would enable users to access ANY page in ANY section by spending those credits on the pages they access, whereby different pages will require different amount of credits

    Does Umbraco or any other open-source CMS (or eCommerce solution) offer this functionality, either natively or via addins?

    Erdöl

Please Sign in or register to post replies

Write your reply to:

Draft