Fix bug when migrating user db with users that have never logged in.

pull/3423/head
Patrick Barron 5 years ago
parent d116497912
commit 8ca78f33e9

@ -282,7 +282,7 @@ namespace Emby.Server.Implementations.Session
if (user != null) if (user != null)
{ {
var userLastActivityDate = user.LastActivityDate; var userLastActivityDate = user.LastActivityDate ?? DateTime.MinValue;
user.LastActivityDate = activityDate; user.LastActivityDate = activityDate;
if ((activityDate - userLastActivityDate).TotalSeconds > 60) if ((activityDate - userLastActivityDate).TotalSeconds > 60)

@ -134,11 +134,8 @@ namespace Emby.Server.Implementations.SyncPlay
var item = _libraryManager.GetItemById(itemId); var item = _libraryManager.GetItemById(itemId);
// Check ParentalRating access // Check ParentalRating access
var hasParentalRatingAccess = true; var hasParentalRatingAccess = !user.MaxParentalAgeRating.HasValue
if (user.MaxParentalAgeRating.HasValue) || item.InheritedParentalRatingValue <= user.MaxParentalAgeRating;
{
hasParentalRatingAccess = item.InheritedParentalRatingValue <= user.MaxParentalAgeRating.Value;
}
if (!user.HasPermission(PermissionKind.EnableAllFolders) && hasParentalRatingAccess) if (!user.HasPermission(PermissionKind.EnableAllFolders) && hasParentalRatingAccess)
{ {
@ -255,8 +252,7 @@ namespace Emby.Server.Implementations.SyncPlay
// TODO: determine what happens to users that are in a group and get their permissions revoked // TODO: determine what happens to users that are in a group and get their permissions revoked
lock (_groupsLock) lock (_groupsLock)
{ {
ISyncPlayController group; _sessionToGroupMap.TryGetValue(session.Id, out var group);
_sessionToGroupMap.TryGetValue(session.Id, out group);
if (group == null) if (group == null)
{ {
@ -329,8 +325,7 @@ namespace Emby.Server.Implementations.SyncPlay
lock (_groupsLock) lock (_groupsLock)
{ {
ISyncPlayController group; _sessionToGroupMap.TryGetValue(session.Id, out var group);
_sessionToGroupMap.TryGetValue(session.Id, out group);
if (group == null) if (group == null)
{ {
@ -340,7 +335,7 @@ namespace Emby.Server.Implementations.SyncPlay
{ {
Type = GroupUpdateType.NotInGroup Type = GroupUpdateType.NotInGroup
}; };
_sessionManager.SendSyncPlayGroupUpdate(session.Id.ToString(), error, CancellationToken.None); _sessionManager.SendSyncPlayGroupUpdate(session.Id, error, CancellationToken.None);
return; return;
} }
@ -367,8 +362,7 @@ namespace Emby.Server.Implementations.SyncPlay
throw new InvalidOperationException("Session not in any group!"); throw new InvalidOperationException("Session not in any group!");
} }
ISyncPlayController tempGroup; _sessionToGroupMap.Remove(session.Id, out var tempGroup);
_sessionToGroupMap.Remove(session.Id, out tempGroup);
if (!tempGroup.GetGroupId().Equals(group.GetGroupId())) if (!tempGroup.GetGroupId().Equals(group.GetGroupId()))
{ {

@ -181,12 +181,12 @@ namespace Jellyfin.Data.Entities
/// <summary> /// <summary>
/// Gets or sets the last activity date. /// Gets or sets the last activity date.
/// </summary> /// </summary>
public DateTime LastActivityDate { get; set; } public DateTime? LastActivityDate { get; set; }
/// <summary> /// <summary>
/// Gets or sets the last login date. /// Gets or sets the last login date.
/// </summary> /// </summary>
public DateTime LastLoginDate { get; set; } public DateTime? LastLoginDate { get; set; }
/// <summary> /// <summary>
/// Gets or sets the number of login attempts the user can make before they are locked out. /// Gets or sets the number of login attempts the user can make before they are locked out.

@ -218,7 +218,7 @@ namespace Jellyfin.Server.Implementations.Users
var dbContext = _dbProvider.CreateContext(); var dbContext = _dbProvider.CreateContext();
if (!dbContext.Users.Contains(user)) if (dbContext.Users.Find(user.Id) == null)
{ {
throw new ArgumentException(string.Format( throw new ArgumentException(string.Format(
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,

@ -196,9 +196,9 @@ namespace Jellyfin.Server.Migrations.Routines
public string EasyPassword { get; set; } public string EasyPassword { get; set; }
public DateTime LastLoginDate { get; set; } public DateTime? LastLoginDate { get; set; }
public DateTime LastActivityDate { get; set; } public DateTime? LastActivityDate { get; set; }
public string Name { get; set; } public string Name { get; set; }

Loading…
Cancel
Save