'Admin' Member authentication - log in without password

Greetings,

I need to implement an ‘admin’ authentication for members. This means it would allow our company’s agents to log in as a member without using their password. This would essentially allow them to look at the member area without their password.

Is there any way to do this with the default member authentication mechanism in 7.6.3, or would it require me to create a custom Identity implementation?

Any insight would be appreciated.

I should add that the routes for this feature would only be accessible to a backoffice user.

Thanks!


This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/86629-admin-member-authentication-log-in-without-password

This can be achieved with the MemberManager & MemberSigninManager

Quite simply, in v13:

using Umbraco.Cms.Core.Security;
using Umbraco.Cms.Web.Common.Security;

public class TokenAuthenticationService : ITokenAuthenticationService
{
    private readonly IMemberSignInManager _memberSignInManager;
    private readonly IMemberManager _memberManager;
    public static string CookieKey = "l_token";


    public TokenAuthenticationService(
        IMemberSignInManager memberSignInManager,
        IMemberManager memberManager)
    {
        _memberSignInManager = memberSignInManager;
        _memberManager = memberManager;
    }

    public async Task<bool> ProcessTokenAuthenticationAsync(HttpRequest request, HttpResponse response)
    {

        //get the memeber
        var memberIdentityUser = await _memberManager.FindByEmailAsync({ member_email});
        if (memberIdentityUser != null)
        {
            //sign in the member
            var signInTask = _memberSignInManager.SignInAsync(memberIdentityUser, true);
            await signInTask;

            if (signInTask.IsCompletedSuccessfully)
            {
                //horay!
            }
        }
    }
}

It can get a bit annoying using an async method, but other than that, it’s not too bad