當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。