本文整理汇总了C#中ApplicationUserManager.IsEmailConfirmed方法的典型用法代码示例。如果您正苦于以下问题:C# ApplicationUserManager.IsEmailConfirmed方法的具体用法?C# ApplicationUserManager.IsEmailConfirmed怎么用?C# ApplicationUserManager.IsEmailConfirmed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApplicationUserManager
的用法示例。
在下文中一共展示了ApplicationUserManager.IsEmailConfirmed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartEbayLoad
public void StartEbayLoad(string username, string password)
{
//var abc = HttpContext.Current.User.Identity.IsAuthenticated;
var logger = UnityConfig.GetConfiguredContainer().Resolve<ILogger>();
if (logger == null) throw new Exception("Logger is null");
logger.Write("LOGGING START",
LoggerCategories.Warning, 0, 0,
TraceEventType.Warning,
"HELLO WORLD",
new Dictionary<string, object>());
#region 'Parameter validation'
if (String.IsNullOrWhiteSpace(username))
{
//Log the error
logger.Write(String.Format("{0} call missing the user name, parameter missing a valid value (mandatory).", StartEbayLoadServiceMethodName),
LoggerCategories.Error, 0, 0,
TraceEventType.Stop,
startEbayLoadMessage,
new Dictionary<string, object>());
//Raise the fault
throw new FaultException<InputParameterFault>(
new InputParameterFault { ErrorDetails = InputParameterFault.FaultCodeUserNameWasNullOrEmpty, ErrorMessage = InputParameterFault.FaultMessageUserNameWasNullOrEmpty, Result = false },
new FaultReason(new FaultReasonText(InputParameterFault.FaultMessageInvalidParameter)), new FaultCode(InputParameterFault.FaultCodeInvalidParameter));
}
if (String.IsNullOrWhiteSpace(password))
{
//Log the error
logger.Write(String.Format("{0} call missing the password, parameter missing a valid value (mandatory).", StartEbayLoadServiceMethodName),
LoggerCategories.Error, 0, 0,
TraceEventType.Stop,
startEbayLoadMessage,
new Dictionary<string, object>());
throw new FaultException<InputParameterFault>(
new InputParameterFault { ErrorDetails = InputParameterFault.FaultCodePasswordWasNullOrEmpty, ErrorMessage = InputParameterFault.FaultMessagePasswordWasNullOrEmpty, Result = false },
new FaultReason(new FaultReasonText(InputParameterFault.FaultMessageInvalidParameter)), new FaultCode(InputParameterFault.FaultCodeInvalidParameter));
}
#endregion 'Parameter validation'
#region "Authentication & Authorisation"
//We perform DB authentication & authorisation of user name and password
userManager = userManager ?? HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>();
AspNetUser user = userManager.Find(username, password);
if (user == null)
{
//Log the error
logger.Write(String.Format("User could not be authenticated with user name = '{0}' and password = '{1}'.", username, password),
LoggerCategories.Error, 0, 0,
TraceEventType.Critical,
startEbayLoadMessage,
new Dictionary<string, object>());
//User not authenticated
throw new FaultException<AuthenticationFault>(
new AuthenticationFault { ErrorDetails = AuthenticationFault.FaultCodeCredentialsCouldNotBeValidated, ErrorMessage = AuthenticationFault.FaultMessageCredentialsCouldNotBeValidated, Result = false },
new FaultReason(new FaultReasonText(AuthenticationFault.FaultMessageCredentialsCouldNotBeValidated)), new FaultCode(AuthenticationFault.FaultCodeCredentialsCouldNotBeValidated));
}
if (!userManager.IsEmailConfirmed(user.Id))
{
//Log the error
logger.Write(String.Format("User's email is not confirmed, user name = '{0}' and password = '{1}'.", username, password),
LoggerCategories.Error, 0, 0,
TraceEventType.Stop,
startEbayLoadMessage,
new Dictionary<string, object>());
//User is not confirm
throw new FaultException<AuthenticationFault>(
new AuthenticationFault { ErrorDetails = AuthenticationFault.FaultCodeEmailNotConfirmed, ErrorMessage = AuthenticationFault.FaultMessageEmailNotConfirmed, Result = false },
new FaultReason(new FaultReasonText(AuthenticationFault.FaultMessageEmailNotConfirmed)), new FaultCode(AuthenticationFault.FaultCodeEmailNotConfirmed));
}
if (user.LockoutEnabled)
{
//Log the error
logger.Write(String.Format("User is locked, user name = '{0}' and password = '{1}'.", username, password),
LoggerCategories.Error, 0, 0,
TraceEventType.Stop,
startEbayLoadMessage,
new Dictionary<string, object>());
//User is locked
throw new FaultException<AuthenticationFault>(
new AuthenticationFault { ErrorDetails = AuthenticationFault.FaultCodeUserIsLocked, ErrorMessage = AuthenticationFault.FaultMessageUserIsLocked, Result = false },
new FaultReason(new FaultReasonText(AuthenticationFault.FaultMessageUserIsLocked)), new FaultCode(AuthenticationFault.FaultCodeUserIsLocked));
}
AspNetRole role = user.AspNetRoles.FirstOrDefault();
if (role != null && role.Id != Utility.AdminRoleId)
{
//Log the error
logger.Write(String.Format("User is not authorised for this operation, user name = '{0}' and password = '{1}' (should have Administrator role).", username, password),
LoggerCategories.Error, 0, 0,
TraceEventType.Stop,
startEbayLoadMessage,
new Dictionary<string, object>());
//.........这里部分代码省略.........