Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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
if(updateLogin) { _membershipHelper.Login(model.Username, model.Password); }
but it didn't help.
Thanks
Hello,
Did you find a solution?
Nothing so far
I had some success with this.
Members.Logout(); 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:
https://github.com/umbraco/Umbraco-CMS/blob/7ee510ed386495120666a78c61497f58ff05de8f/src/Umbraco.Web/Security/MembershipHelper.cs#L287
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Re-authenticate IMember after username/ email change
I am changing username (email which is the same) of a IMember programatically in my umbraco app.
After I save the member's new username and email I cannot longer access member only pages and getting the following error:
How to re-authenticate logged user after username update?
I tried recall
but it didn't help.
Thanks
Hello,
Did you find a solution?
Nothing so far
I had some success with this.
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:
https://github.com/umbraco/Umbraco-CMS/blob/7ee510ed386495120666a78c61497f58ff05de8f/src/Umbraco.Web/Security/MembershipHelper.cs#L287
is working on a reply...