Copied to clipboard

Flag this post as spam?

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


  • DitlevHB 6 posts 66 karma points
    Mar 27, 2015 @ 07:31
    DitlevHB
    0

    Updating member through clientside calls to API

    I'm trying to make a service call from clientside to my api, which should update the currently logged in member.

    The problem is, that after updating the members name, email and username, I cannot fetch the current member by using the Membership helper. 

    So when i try to use the membershipHelper.GetCurrentMember() after updating the member, it returns null.

    I tried updating the member in several different way, to see if that would help, but with no luck.

     

    using Umbraco.Core.Models;

    IMember member = ApplicationContext.Services.MemberService.GetById(_memberHelper.GetCurrentMember().Id);
    member.Username = currentMember.Email;
    member.Email = currentMember.Email;
    member.Name = currentMember.Email;
    ApplicationContext.Services.MemberService.Save(member);

     

    Using deprecated  umbraco.cms.businesslogic.member;

    Member member = Member.GetCurrentMember();
    member.LoginName = currentMember.Email;
    member.Text = currentMember.Email;
    member.Email = currentMember.Email;
    member.Save();

    Updating profilemodel

    var profileModel = _memberHelper.GetCurrentMemberProfileModel();
    profileModel.Name = currentMember.Email;
    profileModel.Email = currentMember.Email;
    profileModel.UserName = currentMember.Email;
     _memberHelper.UpdateMemberProfile(profileModel);

     

    So these result in the currentmember, when trying to fetch the currentMember in another servicecall after updating the member successfully.

    I've searched for a solution for hours. Any help is much appreciated :)

  • Damien Holley 180 posts 541 karma points
    Apr 17, 2017 @ 05:56
    Damien Holley
    0

    I would recommend logout after grabbing the object.

    Update with info

    prompt user to login again using new username etc.

Please Sign in or register to post replies

Write your reply to:

Draft