Fixe l'inscription, affiche un avatar par défaut
This commit is contained in:
@ -43,6 +43,24 @@ namespace Yavsc.Controllers
|
||||
// If some amdin already exists, make this method disapear
|
||||
var admins = await _userManager.GetUsersInRoleAsync(Constants.AdminGroupName);
|
||||
if (admins != null && admins.Count > 0) return HttpNotFound();
|
||||
|
||||
// ensure all roles existence
|
||||
foreach (string roleName in new string[] {Constants.AdminGroupName,
|
||||
Constants.StarGroupName, Constants.PerformerGroupName,
|
||||
Constants.FrontOfficeGroupName,
|
||||
Constants.StarHunterGroupName
|
||||
})
|
||||
if (!await _roleManager.RoleExistsAsync(roleName))
|
||||
{
|
||||
var role = new IdentityRole { Name = roleName };
|
||||
var resultCreate = await _roleManager.CreateAsync(role);
|
||||
if (!resultCreate.Succeeded)
|
||||
{
|
||||
AddErrors(resultCreate);
|
||||
return new BadRequestObjectResult(ModelState);
|
||||
}
|
||||
}
|
||||
|
||||
var user = await _userManager.FindByIdAsync(User.GetUserId());
|
||||
|
||||
IdentityRole adminRole;
|
||||
@ -53,6 +71,7 @@ namespace Yavsc.Controllers
|
||||
AddErrors(addToRoleResult);
|
||||
return new BadRequestObjectResult(ModelState);
|
||||
}
|
||||
|
||||
return Ok(new { message = "you owned it." });
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user