Copied to clipboard

Flag this post as spam?

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


  • Nagarjun 36 posts 67 karma points
    Dec 14, 2020 @ 08:23
    Nagarjun
    0

    Accessing Umbraco services in startup class.

    Hi,

    Can anyone let me know on how to access Umbraco services like logger service , member service, user service in start up class file. I want to assign a different role based on the claims I receive from external identity like Azure active directory.

    public partial class Startup
    {
    public void ConfigureAuth(IAppBuilder app)
    {
    adOptions.SetExternalSignInAutoLinkOptions(
                new ExternalSignInAutoLinkOptions(autoLinkExternalAccount: true, defaultUserGroups: null, defaultCulture: null)
                {
                    OnAutoLinking = (user, externalLogin) => {
    
    
                    }
    
                    ,OnExternalLogin = (user, externalLogin) => {
                        return true;
                    }
    
                });
    
    }
    }
    
  • Dhanesh Kumar MJ 99 posts 318 karma points
    Dec 14, 2020 @ 14:20
    Dhanesh Kumar MJ
    0

    Hi Nagarjuna,

    You can consume services like this

    Example Userservice

    var userService = Umbraco.Core.Composing.Current.Services.UserService;
    

    Regards Dhanesh :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies