Copied to clipboard

Flag this post as spam?

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


  • Dominic Tse 21 posts 110 karma points
    Feb 21, 2017 @ 06:42
    Dominic Tse
    0

    Calling MembershipHelper in Controller

    I tried using Umbraco MembershipHelper in a Controller that inherits from SurfaceController.

    I would like to allow Umbraco back office users can access a page.

    I noticed that MembershipHelper.IsLoggedIn() is always false even I have logged into Umbraco.

    Why?

    According to the documentation, we can use MembershipHelper on a View, Controller etc... https://our.umbraco.org/documentation/reference/querying/membershiphelper/

  • Tim Watts 90 posts 395 karma points
    Feb 21, 2017 @ 08:28
    Tim Watts
    0

    Hi Dominic,

    Membership is a totally different thing to Umbraco Users. There are two different tabs in the back-end for configuration.

    Users are for back-end access, for example to edit content, Members can be used for restricting front end (public) content.

    For more information on membership click here

    Regards,

    Tim

  • Dominic Tse 21 posts 110 karma points
    Feb 21, 2017 @ 22:42
    Dominic Tse
    0

    I would like to allow Umbraco back office users can access a page.

    The controller is intended for Umbraco back end users only. I wanted to create a new Section in the Umbraco backoffice. The new "sample" section directs user to a MVC view.

    application.config

      <add alias="sample" name="sample" icon="trayuser" sortOrder="8" />
    

    Dashboard.config

      <section alias="StartupSampleDashboardSection">
        <areas>
          <area>sample</area>
        </areas>
        <tab caption="Tab A">
          <control>
            /umbraco/surface/sample/index
          </control>
        </tab>
        <tab caption="Tab B">
          <control>
            /umbraco/surface/sample/index
          </control>
        </tab>
      </section>
    
  • Kevin Jump 2342 posts 14889 karma points MVP 8x c-trib
    Feb 21, 2017 @ 08:35
    Kevin Jump
    0

    Hi,

    The membership helper will check to see if members are logged into the front end of your website, not the umbraco back office. there are two 'membership' providers within an umbraco site, Members are for when you're site lets people login and Users are for your editors of the site (via the umbraco) url.

    I am not sure but if you only want back office users to see the controller you may be able to add the UmbracoAuthorize attribute to the class

    [Umbraco.Web.WebApi.UmbracoAuthorize]
    public class controller ....
    

    If the page is something just for your back office users, you might want consider making it a dashboard and adding to to the relevant section in the back office

  • Dominic Tse 21 posts 110 karma points
    Feb 21, 2017 @ 23:27
    Dominic Tse
    0

    Yes only wanted the back end office user to access the Controller. I created a new section on the dashboard.

Please Sign in or register to post replies

Write your reply to:

Draft