本文整理汇总了C#中IOwinContext.GetUserManager方法的典型用法代码示例。如果您正苦于以下问题:C# IOwinContext.GetUserManager方法的具体用法?C# IOwinContext.GetUserManager怎么用?C# IOwinContext.GetUserManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOwinContext
的用法示例。
在下文中一共展示了IOwinContext.GetUserManager方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AuthenticationRepository
public AuthenticationRepository(IOwinContext owinContext)
{
userManager = owinContext.GetUserManager<ApplicationUserManager>();
roleManager = owinContext.Get<ApplicationRoleManager>();
authenticationManager = owinContext.Authentication;
request = owinContext.Request;
}
示例2: CreateApplicationSignInManager
public static ApplicationSignInManager CreateApplicationSignInManager(
IdentityFactoryOptions<ApplicationSignInManager> options,
IOwinContext context)
{
return
new ApplicationSignInManager(
context.GetUserManager<ApplicationUserManager>(),
context.Authentication);
}
示例3: GetIdentityByUserIdAsync
public async Task<ClaimsIdentity> GetIdentityByUserIdAsync(IOwinContext context, string authenticationType, string userId)
{
ClaimsIdentity identity = null;
var userManager = context.GetUserManager<ApplicationUserManager>();
if (userManager != null)
{
var user = await userManager.FindByIdAsync(userId);
if (user != null)
{
identity = await userManager.CreateIdentityAsync(user, authenticationType);
}
}
return identity;
}
示例4: Create
public static ApplicationSignInManager Create(IdentityFactoryOptions<ApplicationSignInManager> options, IOwinContext context)
{
CommonTools._signInManager= new ApplicationSignInManager(context.GetUserManager<ApplicationUserManager>(), context.Authentication);
// return new ApplicationSignInManager(context.GetUserManager<ApplicationUserManager>(), context.Authentication);
return (BlackOwl.Core.Application.ApplicationSignInManager)CommonTools._signInManager;
}
示例5: CreateSignInManager
private static SignInManager<ApplicationUser, string> CreateSignInManager(IdentityFactoryOptions<SignInManager<ApplicationUser, string>> options, IOwinContext context)
{
return new SignInManager<ApplicationUser, string>(context.GetUserManager<UserManager<ApplicationUser>>(), context.Authentication);
}
示例6: UserService
public UserService(IOwinContext context)
{
_userManager = context.GetUserManager<UserManager<User,int>>();
_signinManager = context.Get<SignInManager<User, int>>();
_authManager = context.Authentication;
}
示例7: GetUserByClientAuthorization
private async Task<Tuple<ApplicationUser, string>> GetUserByClientAuthorization(IOwinContext context, string clientAuthorization, string clientRequestUri, string clientRequestMethod, string clientHostName, string clientHostAddress)
{
Tuple<ApplicationUser, string> result = null;
string[] autherizationHeaderArray = ClientApiProvider.GetAutherizationHeaderValues(clientAuthorization);
if (autherizationHeaderArray != null)
{
// Log.Logger.Debug("DuongDQ4");
string apiKey = autherizationHeaderArray[0];
string incomingSignatureHash = autherizationHeaderArray[1];
string nonce = autherizationHeaderArray[2];
string requestTimeStamp = autherizationHeaderArray[3];
var userBll = UnityConfig.GetConfiguredContainer().Resolve<IUserBll>();
UserApp userApp = await userBll.GetUserApp(apiKey);
if (userApp != null && !string.IsNullOrEmpty(userApp.ApiSecret))
{
// Log.Logger.Debug("DuongDQ5: Get user app ok");
if (CheckClientHost(userApp.AppHosts, userApp.AppIps, clientHostName, clientHostAddress))
{
// Log.Logger.Debug("DuongDQ6: check host ok");
bool isValid;
try
{
isValid = ClientApiProvider.isValidRequest(clientRequestUri, clientRequestMethod, userApp.ApiKey, userApp.ApiSecret, incomingSignatureHash, nonce, requestTimeStamp);
}
catch
{
isValid = false;
}
if (isValid)
{
// Log.Logger.Debug("DuongDQ7: Valid request");
var userManager = context.GetUserManager<ApplicationUserManager>();
ApplicationUser user = await userManager.FindByIdAsync(userApp.UserId);
if (user != null)
{
//Log.Logger.Debug(string.Format("{0}: Find user ok", (object)clientHostAddress));
result = new Tuple<ApplicationUser, string>(user, userApp.ApiSecret);
}
else
Log.Logger.Debug(string.Format("{0}: Not found user", clientHostAddress));
}
else
Log.Logger.Debug(string.Format("{0}: Invalid request", clientHostAddress));
}
}
else
Log.Logger.Debug(string.Format("{0}: Invalid api key", clientHostAddress));
}
return result;
}