Copied to clipboard

Flag this post as spam?

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


  • Rob Watkins 369 posts 701 karma points
    Aug 30, 2011 @ 18:03
    Rob Watkins
    0

    umbraco.BusinessLogic.User.GetCurrent() redirecting (v4.7)

    I am creating some AJAX handlers for application functionality, and I want to be able to return responses based on whether an admin user is logged in or not - basically, there is a custom section managing a product database, so handlers for product lists etc. have relevance both in the backend and on the public site - but different relevance.

    The problem I'm having is that when I call umbraco.BusinessLogic.User.GetCurrent() I was expecting it to just return null if no user is logged in, but instead I'm getting redirected to login.aspx (which doesn't actually even exist in the public tree, so I am presuming that the redirect assumes the current directory is /umbraco)

    Can I avoid this, or is there another non-redirecty way of finding out if an admin user is logged in or not?

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Aug 30, 2011 @ 18:15
    Bo Damgaard Mortensen
    0

    Hi Rob,

    Without knowing if it will return null or do the same redirect, have you tried either of the following methods:

    User u = UmbracoEnsuredPage.CurrentUser;

    or

    User user = umbraco.helper.GetCurrentUmbracoUser();

    ? :-)

    Haven't tested the return values (if there's any) Just a suggestion.

    / Bo

  • Rob Watkins 369 posts 701 karma points
    Aug 31, 2011 @ 11:29
    Rob Watkins
    0

    Hi Bo, thanks for those! On another project today but I'll give them a go when I get a chance.

Please Sign in or register to post replies

Write your reply to:

Draft