diff --git a/src/Core/Models/EntityFramework/Organization.cs b/src/Core/Models/EntityFramework/Organization.cs index c90a78b5c0..5660fa125d 100644 --- a/src/Core/Models/EntityFramework/Organization.cs +++ b/src/Core/Models/EntityFramework/Organization.cs @@ -1,11 +1,24 @@ using System.Collections.Generic; +using System.Text.Json; using AutoMapper; namespace Bit.Core.Models.EntityFramework { public class Organization : Table.Organization { + private JsonDocument _twoFactorProvidersJson; + public ICollection Ciphers { get; set; } + + public JsonDocument TwoFactorProvidersJson + { + get => _twoFactorProvidersJson; + set + { + TwoFactorProviders = value.ToString(); + _twoFactorProvidersJson = value; + } + } } public class OrganizationMapperProfile : Profile diff --git a/src/Core/Models/EntityFramework/User.cs b/src/Core/Models/EntityFramework/User.cs index 88640db99f..ed896df604 100644 --- a/src/Core/Models/EntityFramework/User.cs +++ b/src/Core/Models/EntityFramework/User.cs @@ -1,11 +1,24 @@ using System.Collections.Generic; +using System.Text.Json; using AutoMapper; namespace Bit.Core.Models.EntityFramework { public class User : Table.User { + private JsonDocument _twoFactorProvidersJson; + public ICollection Ciphers { get; set; } + + public JsonDocument TwoFactorProvidersJson + { + get => _twoFactorProvidersJson; + set + { + TwoFactorProviders = value.ToString(); + _twoFactorProvidersJson = value; + } + } } public class UserMapperProfile : Profile diff --git a/src/Core/Repositories/EntityFramework/DatabaseContext.cs b/src/Core/Repositories/EntityFramework/DatabaseContext.cs index ed93e06c2b..df28f1e35a 100644 --- a/src/Core/Repositories/EntityFramework/DatabaseContext.cs +++ b/src/Core/Repositories/EntityFramework/DatabaseContext.cs @@ -35,6 +35,12 @@ namespace Bit.Core.Repositories.EntityFramework builder.Entity().Ignore(e => e.Attachments); builder.Entity().Property(e => e.Attachments).HasColumnName("Attachments"); + builder.Entity().Ignore(e => e.TwoFactorProviders); + builder.Entity().Property(e => e.TwoFactorProvidersJson).HasColumnName("TwoFactorProviders"); + + builder.Entity().Ignore(e => e.TwoFactorProviders); + builder.Entity().Property(e => e.TwoFactorProvidersJson).HasColumnName("TwoFactorProviders"); + builder.Entity().ToTable(nameof(User)); builder.Entity().ToTable(nameof(Cipher)); builder.Entity().ToTable(nameof(Organization)); diff --git a/src/Core/Repositories/EntityFramework/OrganizationRepository.cs b/src/Core/Repositories/EntityFramework/OrganizationRepository.cs index 79961543eb..fe16ceb5bd 100644 --- a/src/Core/Repositories/EntityFramework/OrganizationRepository.cs +++ b/src/Core/Repositories/EntityFramework/OrganizationRepository.cs @@ -55,7 +55,7 @@ namespace Bit.Core.Repositories.EntityFramework Use2fa = e.Use2fa, UseEvents = e.UseEvents, UsersGetPremium = e.UsersGetPremium, - Using2fa = e.Use2fa && e.TwoFactorProviders != null && e.TwoFactorProviders != "{}", + Using2fa = e.Use2fa && e.TwoFactorProviders != null, }).ToListAsync(); } }