Copied to clipboard

Flag this post as spam?

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

  • nickornotto 374 posts 856 karma points
    Aug 23, 2017 @ 12:52

    Re-authenticate IMember after username/ email change

    I am changing username (email which is the same) of a IMember programatically in my umbraco app.

                if(model.Email != member.Email)
                    member.Email = model.Email;
                    member.Username = model.UsernameIsEmail ? model.Email : model.Username;
                    updateLogin = true;

    After I save the member's new username and email I cannot longer access member only pages and getting the following error:

    [NullReferenceException: Object reference not set to an instance of an object.]
       Umbraco.Web.Security.MembershipHelper.IsMemberAuthorized(Boolean allowAll, IEnumerable`1 allowTypes, IEnumerable`1 allowGroups, IEnumerable`1 allowMembers) +136
       Umbraco.Web.Security.WebSecurity.IsMemberAuthorized(Boolean allowAll, IEnumerable`1 allowTypes, IEnumerable`1 allowGroups, IEnumerable`1 allowMembers) +145
       Umbraco.Web.Mvc.MemberAuthorizeAttribute.AuthorizeCore(HttpContextBase httpContext) +385
       System.Web.Mvc.AuthorizeAttribute.OnAuthorization(AuthorizationContext filterContext) +160
       System.Web.Mvc.ControllerActionInvoker.InvokeAuthorizationFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor) +97
       System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__19(AsyncCallback asyncCallback, Object asyncState) +743
       System.Web.Mvc.Async.WrappedAsyncResult`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +14
       System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128

    How to re-authenticate logged user after username update?

    I tried recall

                    _membershipHelper.Login(model.Username, model.Password);

    but it didn't help.


  • Osman Coskun 152 posts 355 karma points
    Dec 20, 2017 @ 20:12
    Osman Coskun


    Did you find a solution?

  • nickornotto 374 posts 856 karma points
    Jan 05, 2018 @ 16:06

    Nothing so far

  • Thomas 35 posts 133 karma points c-trib
    Aug 07, 2018 @ 14:39

    I had some success with this.

    FormsAuthentication.SetAuthCookie(member.Username, true);

    Which effectively re-authenticates the user with the new username. If you look at the Umbraco source code you can see the login logic here:

Please Sign in or register to post replies

Write your reply to: