Set the admin to have all claims

This commit is contained in:
tidusjar 2016-05-26 17:31:01 +01:00
parent a679f1a6a1
commit 16bd4f5b71
4 changed files with 87 additions and 20 deletions

View file

@ -61,6 +61,10 @@ namespace PlexRequests.Core
{
MigrateToVersion1700();
}
if (version > 1800 && version <= 1899)
{
MigrateToVersion1800();
}
}
return Db.DbConnection().ConnectionString;
@ -173,5 +177,32 @@ namespace PlexRequests.Core
TableCreation.DropTable(Db.DbConnection(), "User");
TableCreation.DropTable(Db.DbConnection(), "Log");
}
/// <summary>
/// Migrates to version 1.8.
/// <para>This includes updating the admin account to have all roles.</para>
/// </summary>
private void MigrateToVersion1800()
{
try
{
var userMapper = new UserMapper(new UserRepository<UsersModel>(Db));
var users = userMapper.GetUsers();
foreach (var u in users)
{
var claims = new[] { UserClaims.User, UserClaims.Admin, UserClaims.PowerUser };
u.Claims = ByteConverterHelper.ReturnBytes(claims);
userMapper.EditUser(u);
}
}
catch (Exception e)
{
Log.Error(e);
throw;
}
}
}
}