当前位置: 首页>>代码示例>>C#>>正文


C# ApplicationUserManager.IsEmailConfirmed方法代码示例

本文整理汇总了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>());
//.........这里部分代码省略.........
开发者ID:innoist,项目名称:Inventory-POS-IST,代码行数:101,代码来源:TmdEbayIntegrationService.svc.cs


注:本文中的ApplicationUserManager.IsEmailConfirmed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。