mirror of
https://github.com/bitwarden/server.git
synced 2025-04-18 03:28:15 -05:00
map json columns for org and user
This commit is contained in:
parent
9fa7f335bd
commit
002efaafd4
@ -1,11 +1,24 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Text.Json;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
|
|
||||||
namespace Bit.Core.Models.EntityFramework
|
namespace Bit.Core.Models.EntityFramework
|
||||||
{
|
{
|
||||||
public class Organization : Table.Organization
|
public class Organization : Table.Organization
|
||||||
{
|
{
|
||||||
|
private JsonDocument _twoFactorProvidersJson;
|
||||||
|
|
||||||
public ICollection<Cipher> Ciphers { get; set; }
|
public ICollection<Cipher> Ciphers { get; set; }
|
||||||
|
|
||||||
|
public JsonDocument TwoFactorProvidersJson
|
||||||
|
{
|
||||||
|
get => _twoFactorProvidersJson;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
TwoFactorProviders = value.ToString();
|
||||||
|
_twoFactorProvidersJson = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class OrganizationMapperProfile : Profile
|
public class OrganizationMapperProfile : Profile
|
||||||
|
@ -1,11 +1,24 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Text.Json;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
|
|
||||||
namespace Bit.Core.Models.EntityFramework
|
namespace Bit.Core.Models.EntityFramework
|
||||||
{
|
{
|
||||||
public class User : Table.User
|
public class User : Table.User
|
||||||
{
|
{
|
||||||
|
private JsonDocument _twoFactorProvidersJson;
|
||||||
|
|
||||||
public ICollection<Cipher> Ciphers { get; set; }
|
public ICollection<Cipher> Ciphers { get; set; }
|
||||||
|
|
||||||
|
public JsonDocument TwoFactorProvidersJson
|
||||||
|
{
|
||||||
|
get => _twoFactorProvidersJson;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
TwoFactorProviders = value.ToString();
|
||||||
|
_twoFactorProvidersJson = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UserMapperProfile : Profile
|
public class UserMapperProfile : Profile
|
||||||
|
@ -35,6 +35,12 @@ namespace Bit.Core.Repositories.EntityFramework
|
|||||||
builder.Entity<Cipher>().Ignore(e => e.Attachments);
|
builder.Entity<Cipher>().Ignore(e => e.Attachments);
|
||||||
builder.Entity<Cipher>().Property(e => e.Attachments).HasColumnName("Attachments");
|
builder.Entity<Cipher>().Property(e => e.Attachments).HasColumnName("Attachments");
|
||||||
|
|
||||||
|
builder.Entity<User>().Ignore(e => e.TwoFactorProviders);
|
||||||
|
builder.Entity<User>().Property(e => e.TwoFactorProvidersJson).HasColumnName("TwoFactorProviders");
|
||||||
|
|
||||||
|
builder.Entity<Organization>().Ignore(e => e.TwoFactorProviders);
|
||||||
|
builder.Entity<Organization>().Property(e => e.TwoFactorProvidersJson).HasColumnName("TwoFactorProviders");
|
||||||
|
|
||||||
builder.Entity<User>().ToTable(nameof(User));
|
builder.Entity<User>().ToTable(nameof(User));
|
||||||
builder.Entity<Cipher>().ToTable(nameof(Cipher));
|
builder.Entity<Cipher>().ToTable(nameof(Cipher));
|
||||||
builder.Entity<Organization>().ToTable(nameof(Organization));
|
builder.Entity<Organization>().ToTable(nameof(Organization));
|
||||||
|
@ -55,7 +55,7 @@ namespace Bit.Core.Repositories.EntityFramework
|
|||||||
Use2fa = e.Use2fa,
|
Use2fa = e.Use2fa,
|
||||||
UseEvents = e.UseEvents,
|
UseEvents = e.UseEvents,
|
||||||
UsersGetPremium = e.UsersGetPremium,
|
UsersGetPremium = e.UsersGetPremium,
|
||||||
Using2fa = e.Use2fa && e.TwoFactorProviders != null && e.TwoFactorProviders != "{}",
|
Using2fa = e.Use2fa && e.TwoFactorProviders != null,
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user