From f40d46e1d9ecdfd83a370270a91e7b581c4fca3b Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Thu, 4 Aug 2016 13:42:17 +0200 Subject: [PATCH] =?UTF-8?q?le=20role=20existe=20d=C3=A9j=C3=A0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Yavsc/Controllers/AdministrationController.cs | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/Yavsc/Controllers/AdministrationController.cs b/Yavsc/Controllers/AdministrationController.cs index 82d0f08f..ae3d2a48 100644 --- a/Yavsc/Controllers/AdministrationController.cs +++ b/Yavsc/Controllers/AdministrationController.cs @@ -40,17 +40,7 @@ namespace Yavsc.Controllers var user = await _userManager.FindByIdAsync(User.GetUserId()); IdentityRole adminRole; - if (!await _roleManager.RoleExistsAsync(Constants.AdminGroupName)) - { - adminRole = new IdentityRole { Name = Constants.AdminGroupName }; - var resultCreate = await _roleManager.CreateAsync(adminRole); - if (!resultCreate.Succeeded) - { - AddErrors(resultCreate); - return new BadRequestObjectResult(ModelState); - } - } - else adminRole = await _roleManager.FindByNameAsync(Constants.AdminGroupName); + adminRole = await _roleManager.FindByNameAsync(Constants.AdminGroupName); var addToRoleResult = await _userManager.AddToRoleAsync(user, Constants.AdminGroupName); if (!addToRoleResult.Succeeded) { @@ -81,7 +71,6 @@ namespace Yavsc.Controllers }); } - private void AddErrors(IdentityResult result) { foreach (var error in result.Errors)