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


C# Identity.IdentityResult类代码示例

本文整理汇总了C#中Microsoft.AspNetCore.Identity.IdentityResult的典型用法代码示例。如果您正苦于以下问题:C# IdentityResult类的具体用法?C# IdentityResult怎么用?C# IdentityResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IdentityResult类属于Microsoft.AspNetCore.Identity命名空间,在下文中一共展示了IdentityResult类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddErrors

 private void AddErrors(IdentityResult result)
 {
     foreach (var error in result.Errors)
     {
         ModelState.AddModelError(string.Empty, error.Description);
     }
 }
开发者ID:ZhangYuef,项目名称:Survey_Platform_ccer,代码行数:7,代码来源:ManageController.cs

示例2: AddIdentityErrors

        public static void AddIdentityErrors(this ModelStateDictionary modelState, IdentityResult result)
        {
            foreach (var error in result.Errors)
            {
                modelState.AddModelError(string.Empty, error.Description);
            }

        }
开发者ID:causer,项目名称:Itasu,代码行数:8,代码来源:ModelStateExtensions.cs

示例3: Failed

 /// <summary>
 /// Creates an <see cref="IdentityResult"/> indicating a failed identity operation, with a list of <paramref name="errors"/> if applicable.
 /// </summary>
 /// <param name="errors">An optional array of <see cref="IdentityError"/>s which caused the operation to fail.</param>
 /// <returns>An <see cref="IdentityResult"/> indicating a failed identity operation, with a list of <paramref name="errors"/> if applicable.</returns>
 public static IdentityResult Failed(params IdentityError[] errors)
 {
     var result = new IdentityResult { Succeeded = false };
     if (errors != null)
     {
         result._errors.AddRange(errors);
     }
     return result;
 }
开发者ID:yonglehou,项目名称:Identity-1,代码行数:14,代码来源:IdentityResult.cs

示例4: AddErrors

 private void AddErrors(IdentityResult result)
 {
     foreach (var error in result.Errors)
     {
         ModelState.AddModelError("", error.Description);
         _logger.LogWarning("Error in creating user: {error}", error.Description);
     }
 }
开发者ID:Cream2015,项目名称:MusicStore,代码行数:8,代码来源:AccountController.cs

示例5: CheckResult

        private IActionResult CheckResult(IdentityResult result)
        {
            if (result == null)
            {
                // No error code
                return BadRequest();
            }            
            
            if (!result.Succeeded)
            {                
                var errors = result.Errors.Select(x => this.TransformError(x.Code));

                var error = new ErrorResponse(errors.First().Item1, errors.First().Item2.ToString());

                error.Parameter_Errors = errors
                    .GroupBy(x => x.Item1, x => x.Item2)
                    .ToDictionary(x => x.Key, x => x.Select(y => y.ToString())
                    .ToArray());

                return this.BadRequest(error);
            }

            return this.Ok();
        }
开发者ID:cschleiden,项目名称:imperaplus-backend,代码行数:24,代码来源:AccountController.cs

示例6: GetErrorResult


//.........这里部分代码省略.........
        //            }

        //            if (_signInManager != null)
        //            {
        //                _signInManager.Dispose();
        //                _signInManager = null;
        //            }
        //        }

        //        base.Dispose(disposing);
        //    }

        //    #region Helpers
        //    // Used for XSRF protection when adding external logins
        //    private const string XsrfKey = "XsrfId";

        //    private IAuthenticationManager AuthenticationManager
        //    {
        //        get
        //        {
        //            return HttpContext.GetOwinContext().Authentication;
        //        }
        //    }

        //    private void AddErrors(IdentityResult result)
        //    {
        //        foreach (var error in result.Errors)
        //        {
        //            ModelState.AddModelError("", error);
        //        }
        //    }

        //    private ActionResult RedirectToLocal(string returnUrl)
        //    {
        //        if (Url.IsLocalUrl(returnUrl))
        //        {
        //            return Redirect(returnUrl);
        //        }
        //        return RedirectToAction("Index", "Home");
        //    }

        //    internal class ChallengeResult : HttpUnauthorizedResult
        //    {
        //        public ChallengeResult(string provider, string redirectUri)
        //            : this(provider, redirectUri, null)
        //        {
        //        }

        //        public ChallengeResult(string provider, string redirectUri, string userId)
        //        {
        //            LoginProvider = provider;
        //            RedirectUri = redirectUri;
        //            UserId = userId;
        //        }

        //        public string LoginProvider { get; set; }
        //        public string RedirectUri { get; set; }
        //        public string UserId { get; set; }

        //        public override void ExecuteResult(ControllerContext context)
        //        {
        //            var properties = new AuthenticationProperties { RedirectUri = RedirectUri };
        //            if (UserId != null)
        //            {
        //                properties.Dictionary[XsrfKey] = UserId;
        //            }
        //            context.HttpContext.GetOwinContext().Authentication.Challenge(properties, LoginProvider);
        //        }
        //    }

        #region Helpers

        private IActionResult GetErrorResult(IdentityResult result)
        {
            if (result == null)
            {
              //  return InternalS();
            }

            if (!result.Succeeded)
            {
                if (result.Errors != null)
                {
                    foreach (var error in result.Errors)
                    {
                        ModelState.AddModelError("", error.Code);
                    }
                }

                if (ModelState.IsValid)
                {
                    // No ModelState errors are available to send, so just return an empty BadRequest.
                    return BadRequest();
                }

                return BadRequest(ModelState);
            }

            return null;
        }
开发者ID:parys,项目名称:MyLiverpool,代码行数:101,代码来源:AccountController.cs

示例7: AddErrors

 private void AddErrors(IdentityResult result)
 {
     foreach (var error in result.Errors)
     {
         ModelState.AddModelError("", error);
     }
 }
开发者ID:yonglehou,项目名称:Identity-1,代码行数:7,代码来源:AccountController.cs


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