Fixed the emby connect issue

pull/3703/head
tidusjar 4 years ago
parent c1529da0e6
commit bffa7d33d4

@ -34,7 +34,6 @@ namespace Ombi.Api.Emby.Models
public string Name { get; set; }
public string ServerId { get; set; }
public string ConnectUserName { get; set; }
public string ConnectUserId { get; set; }
public string ConnectLinkType { get; set; }
public string Id { get; set; }
public bool HasPassword { get; set; }

@ -79,7 +79,7 @@ namespace Ombi.Core.Authentication
{
return await CheckPlexPasswordAsync(user, password);
}
if (user.UserType == UserType.EmbyUser)
if (user.UserType == UserType.EmbyUser || user.UserType == UserType.EmbyConnectUser)
{
return await CheckEmbyPasswordAsync(user, password);
}

@ -80,7 +80,7 @@ namespace Ombi.Schedule.Jobs.Emby
Api = _apiFactory.CreateClient(settings);
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
.SendAsync(NotificationHub.NotificationEvent, "Emby User Importer Started");
.SendAsync(NotificationHub.NotificationEvent, $"{(settings.IsJellyfin ? "Jellyfin" : "Emby")} User Importer Started");
var allUsers = await _userManager.Users.Where(x => x.UserType == UserType.EmbyUser).ToListAsync();
foreach (var server in settings.Servers)
{
@ -98,8 +98,7 @@ namespace Ombi.Schedule.Jobs.Emby
// Do not import these, they are not allowed into the country.
continue;
}
// Check if this Plex User already exists
// We are using the Plex USERNAME and Not the TITLE, the Title is for HOME USERS
// Check if this Emby User already exists
var existingEmbyUser = allUsers.FirstOrDefault(x => x.ProviderUserId == embyUser.Id);
if (existingEmbyUser == null)
{
@ -109,16 +108,14 @@ namespace Ombi.Schedule.Jobs.Emby
_log.LogInformation("Could not create Emby user since the have no username, PlexUserId: {0}", embyUser.Id);
continue;
}
var isConnectUser = embyUser.ConnectUserName.HasValue();
// Create this users
// We do not store a password against the user since they will authenticate via Plex
var newUser = new OmbiUser
{
UserType = UserType.EmbyUser,
UserName = embyUser.ConnectUserName.HasValue() ? embyUser.ConnectUserName : embyUser.Name,
UserType = isConnectUser ? UserType.EmbyConnectUser : UserType.EmbyUser,
UserName = isConnectUser ? embyUser.ConnectUserName : embyUser.Name,
ProviderUserId = embyUser.Id,
Alias = string.Empty,
EmbyConnectUserId = embyUser.ConnectUserId.HasValue() ? embyUser.ConnectUserId : string.Empty,
Alias = isConnectUser ? embyUser.Name : string.Empty,
MovieRequestLimit = userManagementSettings.MovieRequestLimit,
EpisodeRequestLimit = userManagementSettings.EpisodeRequestLimit
};
@ -143,8 +140,6 @@ namespace Ombi.Schedule.Jobs.Emby
{
// Do we need to update this user?
existingEmbyUser.UserName = embyUser.Name;
existingEmbyUser.EmbyConnectUserId =
embyUser.ConnectUserId.HasValue() ? embyUser.ConnectUserId : string.Empty;
if (existingEmbyUser.IsEmbyConnect)
{
@ -152,6 +147,7 @@ namespace Ombi.Schedule.Jobs.Emby
// Since we need the username and password to connect to emby connect,
// We update the email address in the OmbiUserManager when the emby connect user logs in
existingEmbyUser.UserName = embyUser.ConnectUserName;
existingEmbyUser.Alias = embyUser.Name;
}
await _userManager.UpdateAsync(existingEmbyUser);

@ -19,8 +19,6 @@ namespace Ombi.Store.Entities
public DateTime? LastLoggedIn { get; set; }
public string EmbyConnectUserId { get; set; }
public string Language { get; set; }
public int? MovieRequestLimit { get; set; }
@ -33,7 +31,7 @@ namespace Ombi.Store.Entities
public List<UserNotificationPreferences> UserNotificationPreferences { get; set; }
[NotMapped]
public bool IsEmbyConnect => UserType == UserType.EmbyUser && EmbyConnectUserId.HasValue();
public bool IsEmbyConnect => UserType == UserType.EmbyConnectUser;
[NotMapped]
public virtual string UserAlias => string.IsNullOrEmpty(Alias) ? UserName : Alias;

@ -33,5 +33,6 @@ namespace Ombi.Store.Entities
LocalUser = 1,
PlexUser = 2,
EmbyUser = 3,
EmbyConnectUser = 4,
}
}

@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Ombi.Store.Migrations.OmbiMySql
{
public partial class RemoveEmbyConnectionid : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "EmbyConnectUserId",
table: "AspNetUsers");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "EmbyConnectUserId",
table: "AspNetUsers",
type: "longtext CHARACTER SET utf8mb4",
nullable: true);
}
}
}

@ -263,9 +263,6 @@ namespace Ombi.Store.Migrations.OmbiMySql
b.Property<bool>("EmailConfirmed")
.HasColumnType("tinyint(1)");
b.Property<string>("EmbyConnectUserId")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<int?>("EpisodeRequestLimit")
.HasColumnType("int");

@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Ombi.Store.Migrations.OmbiSqlite
{
public partial class RemoveEmbyConnectionid : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "EmbyConnectUserId",
table: "AspNetUsers");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "EmbyConnectUserId",
table: "AspNetUsers",
type: "TEXT",
nullable: true);
}
}
}

@ -262,9 +262,6 @@ namespace Ombi.Store.Migrations.OmbiSqlite
b.Property<bool>("EmailConfirmed")
.HasColumnType("INTEGER");
b.Property<string>("EmbyConnectUserId")
.HasColumnType("TEXT");
b.Property<int?>("EpisodeRequestLimit")
.HasColumnType("INTEGER");

@ -0,0 +1,14 @@
{
"OmbiDatabase": {
"Type": "MySQL",
"ConnectionString": "Server=192.168.68.118;Database=app.ombi.io;User=ombi"
},
"SettingsDatabase": {
"Type": "MySQL",
"ConnectionString": "Server=192.168.68.118;Database=app.ombi.io;User=ombi"
},
"ExternalDatabase": {
"Type": "MySQL",
"ConnectionString": "Server=192.168.68.118;Database=app.ombi.io;User=ombi"
}
}
Loading…
Cancel
Save