Copied to clipboard

Flag this post as spam?

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


  • Wil Jones 11 posts 31 karma points
    Aug 27, 2015 @ 11:35
    Wil Jones
    0

    Get Key for Member

    Hi,

    I have an edit profile page where I'm populating the profile fields, (email, name, etc) from a Web API service I've created which looks up the member by the Id.

    EG /Umbraco/Api/MemberGetProperties/GetMemberProperties?id=2488

    But this is not secure, you could get at Id's and get data returned.

    I can see that a member has a unique key associated with it, and I can get the member from the GetByKey() method.

    But how to I get the Key in the first place? I want to use this in the url.

    In the backoffice this key is used, but I can't find how this is output.

    Thanks

  • Harvey 28 posts 117 karma points
    Mar 22, 2016 @ 10:34
    Harvey
    1

    I'm getting the same problem.

    Seems that keys haven't been added to IPublishedContent yet because it breaks backwards compatibility:

    https://github.com/umbraco/Umbraco-CMS/blob/d50e49ad37fd5ca7bad2fd6e8fc994f3408ae70c/src/Umbraco.Core/Models/IPublishedContentWithKey.cs

    Maybe the only way we can get the key is by getting an IMember straight from the database:

    var MemberService = UmbracoContext.Current.Application.Services.MemberService;
    var memberId = 1234;
    var iMember = MemberService.GetById(memberId);
    var key = iMember.Key;
    

    We should be able to use the GetKey() when Umbraco 8 comes. I have heard that Umbraco 8 is reimplementing the database cache, so I guess that keys will be added properly then.

  • Ayo Adesina 400 posts 977 karma points
    Jan 26, 2017 @ 10:32
    Ayo Adesina
    0

    I'm doing some work with iMember.Key value which is a GUID, so just out of curiosity where is this value stored in the db...

    I opened my umbraco Db.. looked in pretty much every table and I can't find it...

    Can anyone shed any light on this?

  • Geoff Beaumont 75 posts 102 karma points
    Feb 20, 2018 @ 11:48
    Geoff Beaumont
    0

    It's uniqueIdentifier (IIRC) in the umbracoNode table.

  • Jonathon Cove 5 posts 75 karma points
    Mar 03, 2020 @ 15:44
    Jonathon Cove
    0

    In case anyone comes to this issue in Umbraco 8, the below works to get the Guid and Udi of an IPublishedContent:

    using Umbraco.Core;    
    
    var publishedCont = Umbraco.ContentAtRoot().First(); //Where Umbraco is the UmbracoHelper
    var key = publishedCont.Key;
    var udi = Udi.Create("document", key); //either a document, media or member
    

    I don't like manually typing "document", but I can't find a way to get it.

  • Rodolphe Toots 11 posts 91 karma points
    Mar 22, 2020 @ 11:03
    Rodolphe Toots
    1

    Instead of manually typing the magic string "document" you can use the UdiEntitype and write like this:

     Udi.Create(UdiEntityType.Document, key)
    
Please Sign in or register to post replies

Write your reply to:

Draft