mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-06-03 13:44:22 -04:00
Changed UserName to non-deterministic field
This commit is contained in:
parent
d07e1a13b3
commit
379a104cfb
@ -25,7 +25,7 @@ services:
|
|||||||
image: postgres:17.2
|
image: postgres:17.2
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- postgres-data:/var/lib/postgresql/data
|
- ./pgdata/var/lib/postgresql/data
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_PASSWORD: jellyfin
|
POSTGRES_PASSWORD: jellyfin
|
||||||
POSTGRES_USER: jellyfin
|
POSTGRES_USER: jellyfin
|
||||||
@ -47,5 +47,4 @@ services:
|
|||||||
# (Adding the "ports" property to this file will not forward from a Codespace.)
|
# (Adding the "ports" property to this file will not forward from a Codespace.)
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres-data:
|
|
||||||
pgadmin-data:
|
pgadmin-data:
|
||||||
|
@ -390,7 +390,7 @@ public class UserController : BaseJellyfinApiController
|
|||||||
return StatusCode(StatusCodes.Status403Forbidden, "User update not allowed.");
|
return StatusCode(StatusCodes.Status403Forbidden, "User update not allowed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.Equals(user.Username, updateUser.Name, StringComparison.Ordinal))
|
if (!string.Equals(user.Username, updateUser.Name, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
await _userManager.RenameUser(user, updateUser.Name).ConfigureAwait(false);
|
await _userManager.RenameUser(user, updateUser.Name).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,7 @@ namespace Jellyfin.Server.Implementations.ModelConfiguration
|
|||||||
public void Configure(EntityTypeBuilder<User> builder)
|
public void Configure(EntityTypeBuilder<User> builder)
|
||||||
{
|
{
|
||||||
builder
|
builder
|
||||||
.Property(user => user.Username)
|
.Property(user => user.Username);
|
||||||
.UseCollation("NOCASE");
|
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.HasOne(u => u.ProfileImage)
|
.HasOne(u => u.ProfileImage)
|
||||||
|
@ -12,9 +12,6 @@ namespace Jellyfin.Database.Providers.PgSql.Migrations
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
// shim NOCASE collation with an undefined locale and case-insensitive matching rules.
|
|
||||||
migrationBuilder.Sql("CREATE COLLATION NOCASE (provider = icu, locale = 'und-x-icu.utf8', deterministic = false)");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "ActivityLogs",
|
name: "ActivityLogs",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
@ -230,7 +227,7 @@ namespace Jellyfin.Database.Providers.PgSql.Migrations
|
|||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
Username = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false, collation: "NOCASE"),
|
Username = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
||||||
Password = table.Column<string>(type: "character varying(65535)", maxLength: 65535, nullable: true),
|
Password = table.Column<string>(type: "character varying(65535)", maxLength: 65535, nullable: true),
|
||||||
MustUpdatePassword = table.Column<bool>(type: "boolean", nullable: false),
|
MustUpdatePassword = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
AudioLanguagePreference = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
|
AudioLanguagePreference = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
|
||||||
|
@ -147,7 +147,7 @@ namespace Jellyfin.Server.Implementations.Users
|
|||||||
|
|
||||||
ThrowIfInvalidUsername(newName);
|
ThrowIfInvalidUsername(newName);
|
||||||
|
|
||||||
if (user.Username.Equals(newName, StringComparison.Ordinal))
|
if (user.Username.Equals(newName, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
throw new ArgumentException("The new and old names must be different.");
|
throw new ArgumentException("The new and old names must be different.");
|
||||||
}
|
}
|
||||||
@ -155,8 +155,11 @@ namespace Jellyfin.Server.Implementations.Users
|
|||||||
var dbContext = await _dbProvider.CreateDbContextAsync().ConfigureAwait(false);
|
var dbContext = await _dbProvider.CreateDbContextAsync().ConfigureAwait(false);
|
||||||
await using (dbContext.ConfigureAwait(false))
|
await using (dbContext.ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
|
#pragma warning disable CA1862 // Use the 'StringComparison' method overloads to perform case-insensitive string comparisons
|
||||||
|
#pragma warning disable CA1311 // Specify a culture or use an invariant version to avoid implicit dependency on current culture
|
||||||
|
#pragma warning disable CA1304 // The behavior of 'string.ToUpper()' could vary based on the current user's locale settings
|
||||||
if (await dbContext.Users
|
if (await dbContext.Users
|
||||||
.AnyAsync(u => u.Username == newName && !u.Id.Equals(user.Id))
|
.AnyAsync(u => u.Username.ToUpper() == newName.ToUpper() && !u.Id.Equals(user.Id))
|
||||||
.ConfigureAwait(false))
|
.ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
throw new ArgumentException(string.Format(
|
throw new ArgumentException(string.Format(
|
||||||
@ -164,6 +167,9 @@ namespace Jellyfin.Server.Implementations.Users
|
|||||||
"A user with the name '{0}' already exists.",
|
"A user with the name '{0}' already exists.",
|
||||||
newName));
|
newName));
|
||||||
}
|
}
|
||||||
|
#pragma warning restore CA1304 // The behavior of 'string.ToUpper()' could vary based on the current user's locale settings
|
||||||
|
#pragma warning restore CA1311 // Specify a culture or use an invariant version to avoid implicit dependency on current culture
|
||||||
|
#pragma warning restore CA1862 // Use the 'StringComparison' method overloads to perform case-insensitive string comparisons
|
||||||
|
|
||||||
user.Username = newName;
|
user.Username = newName;
|
||||||
await UpdateUserInternalAsync(dbContext, user).ConfigureAwait(false);
|
await UpdateUserInternalAsync(dbContext, user).ConfigureAwait(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user