using System;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin;
using Umbraco.Core.Models.Identity;
using Umbraco.Core.Security;
using Umbraco.Web.Models.Identity;
namespace Umbraco.Web.Security
{
///
/// This class is only here due to the fact that IOwinContext Get / Set only work in generics, if they worked
/// with regular 'object' then we wouldn't have to use this work around but because of that we have to use this
/// class to resolve the 'real' type of the registered user manager
///
///
///
internal class BackOfficeUserManagerMarker : IBackOfficeUserManagerMarker
where TManager : BackOfficeUserManager
where TUser : BackOfficeIdentityUser
{
public BackOfficeUserManager GetManager(IOwinContext owin)
{
var mgr = owin.Get() as BackOfficeUserManager;
if (mgr == null) throw new InvalidOperationException("Could not cast the registered back office user of type " + typeof(TManager) + " to " + typeof(BackOfficeUserManager));
return mgr;
}
}
}