diff --git a/src/Ombi/Controllers/IdentityController.cs b/src/Ombi/Controllers/IdentityController.cs index 58ba1b7c1..8e28a18c4 100644 --- a/src/Ombi/Controllers/IdentityController.cs +++ b/src/Ombi/Controllers/IdentityController.cs @@ -472,8 +472,16 @@ namespace Ombi.Controllers // Get the roles var userRoles = await UserManager.GetRolesAsync(user); + // Am I modifying myself? + var modifyingSelf = user.UserName.Equals(User.Identity.Name, StringComparison.CurrentCultureIgnoreCase); + foreach (var role in userRoles) { + if (modifyingSelf && role.Equals(OmbiRoles.Admin)) + { + // We do not want to remove the admin role from yourself, this must be an accident + continue; + } await UserManager.RemoveFromRoleAsync(user, role); }