コード例 #1
0
        private async Task UpdateIdentityClaims(EditUserModel model, ApplicationUser user)
        {
            var claims = await userManager.GetClaimsAsync(user);

            await AddOrReplaceClaim(claims, JwtClaimTypes.Name, model.FullName, user);
            await AddOrReplaceClaim(claims, JwtClaimTypes.Email, model.Email, user);

            user.Email              = model.Email;
            user.UserName           = model.Email;
            user.NormalizedUserName = model.Email.ToUpper();
            await userManager.UpdateAsync(user);
        }
コード例 #2
0
        public Task <IActionResult> EditUser(EditUserModel model, string button)
        {
            switch (button)
            {
            case "Update": return(UpdateUser(model));

            case "Delete": return(Task.FromResult((IActionResult)View("DeleteConfirm", model)));

            case "NoDelete": return(Task.FromResult((IActionResult)View(model)));

            case "YesDelete": return(DeleteUser(model));

            case "Impersonate": return(ImpersonateUser(model));

            case "PasswordReset": return(TryPasswordReset(model));
            }
            throw new InvalidOperationException("Invalid Button");
        }
コード例 #3
0
        private async Task <IActionResult> DeleteUser(EditUserModel model)
        {
            await userManager.DeleteAsync(await userManager.FindByIdAsync(model.Id));

            return(Redirect("/"));
        }