Copied to clipboard

Flag this post as spam?

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


  • James C 17 posts 138 karma points
    Feb 21, 2018 @ 11:33
    James C
    0

    Umbraco Backoffice Sign in Call

    Hi,

    I would like to make a call to the same function that is called on clicking the backoffice sign in button. I am unsure what that would be, if anyone could let me know what I need to call or point me in the right direction please.

    Thank you in advance.

  • James C 17 posts 138 karma points
    Feb 22, 2018 @ 09:28
    James C
    100

    After examining the Umbraco source code, I was able to achieve this in front end and backend code.

    In front end I created a jQuery ajax call to the following endpoint: '/umbraco/backoffice/UmbracoApi/Authentication/PostLogin'. I also passed in username and password details as JSON object.

    In back end I used the following code from a UmbracoApiController:

    private async Task<SignInStatus> LoginAsync(LoginModel loginModel)
        {
            // Get http context
            var http = this.TryGetHttpContext();
            // Get owin context
            var owinContext = TryGetOwinContext().Result;
            // Get backoffice sign in manager
            var signInManager = TryGetOwinContext().Result.GetBackOfficeSignInManager();
            // Call sign in method
            var result = await signInManager.PasswordSignInAsync(loginModel.Username, loginModel.Password, true, true);
    
            return result;
        }
    
  • 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