mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-30 19:40:05 -07:00
Set the admin to have all claims
This commit is contained in:
parent
a679f1a6a1
commit
16bd4f5b71
4 changed files with 87 additions and 20 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue