mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 00:22:50 -05:00
Enable Nullable In Auth Repositories (#4600)
This commit is contained in:
@ -8,6 +8,8 @@ using Bit.Infrastructure.EntityFramework.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Auth.Repositories;
|
||||
|
||||
public class AuthRequestRepository : Repository<Core.Auth.Entities.AuthRequest, AuthRequest, Guid>, IAuthRequestRepository
|
||||
@ -25,7 +27,7 @@ public class AuthRequestRepository : Repository<Core.Auth.Entities.AuthRequest,
|
||||
var expiredRequests = await dbContext.AuthRequests
|
||||
.Where(a => (a.Type != AuthRequestType.AdminApproval && a.CreationDate.AddSeconds(userRequestExpiration.TotalSeconds) < DateTime.UtcNow)
|
||||
|| (a.Type == AuthRequestType.AdminApproval && a.Approved != true && a.CreationDate.AddSeconds(adminRequestExpiration.TotalSeconds) < DateTime.UtcNow)
|
||||
|| (a.Type == AuthRequestType.AdminApproval && a.Approved == true && a.ResponseDate.Value.AddSeconds(afterAdminApprovalExpiration.TotalSeconds) < DateTime.UtcNow))
|
||||
|| (a.Type == AuthRequestType.AdminApproval && a.Approved == true && a.ResponseDate!.Value.AddSeconds(afterAdminApprovalExpiration.TotalSeconds) < DateTime.UtcNow))
|
||||
.ToListAsync();
|
||||
dbContext.AuthRequests.RemoveRange(expiredRequests);
|
||||
return await dbContext.SaveChangesAsync();
|
||||
|
@ -10,6 +10,8 @@ using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Auth.Repositories;
|
||||
|
||||
public class EmergencyAccessRepository : Repository<Core.Auth.Entities.EmergencyAccess, EmergencyAccess, Guid>, IEmergencyAccessRepository
|
||||
@ -35,7 +37,7 @@ public class EmergencyAccessRepository : Repository<Core.Auth.Entities.Emergency
|
||||
await base.DeleteAsync(emergencyAccess);
|
||||
}
|
||||
|
||||
public async Task<EmergencyAccessDetails> GetDetailsByIdGrantorIdAsync(Guid id, Guid grantorId)
|
||||
public async Task<EmergencyAccessDetails?> GetDetailsByIdGrantorIdAsync(Guid id, Guid grantorId)
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
|
@ -6,6 +6,8 @@ using Bit.Infrastructure.EntityFramework.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Auth.Repositories;
|
||||
|
||||
public class GrantRepository : BaseEntityFrameworkRepository, IGrantRepository
|
||||
@ -36,7 +38,7 @@ public class GrantRepository : BaseEntityFrameworkRepository, IGrantRepository
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IGrant> GetByKeyAsync(string key)
|
||||
public async Task<IGrant?> GetByKeyAsync(string key)
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
@ -92,4 +94,3 @@ public class GrantRepository : BaseEntityFrameworkRepository, IGrantRepository
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
using Bit.Infrastructure.EntityFramework.Repositories;
|
||||
using Bit.Infrastructure.EntityFramework.Repositories.Queries;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Auth.Repositories.Queries;
|
||||
|
||||
public class EmergencyAccessDetailsViewQuery : IQuery<EmergencyAccessDetails>
|
||||
|
@ -2,6 +2,8 @@
|
||||
using Bit.Infrastructure.EntityFramework.Repositories;
|
||||
using Bit.Infrastructure.EntityFramework.Repositories.Queries;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Auth.Repositories.Queries;
|
||||
|
||||
public class EmergencyAccessReadCountByGrantorIdEmailQuery : IQuery<EmergencyAccess>
|
||||
|
@ -4,6 +4,8 @@ using Bit.Infrastructure.EntityFramework.Auth.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Repositories;
|
||||
|
||||
public class SsoConfigRepository : Repository<Core.Auth.Entities.SsoConfig, SsoConfig, long>, ISsoConfigRepository
|
||||
@ -12,7 +14,7 @@ public class SsoConfigRepository : Repository<Core.Auth.Entities.SsoConfig, SsoC
|
||||
: base(serviceScopeFactory, mapper, (DatabaseContext context) => context.SsoConfigs)
|
||||
{ }
|
||||
|
||||
public async Task<Core.Auth.Entities.SsoConfig> GetByOrganizationIdAsync(Guid organizationId)
|
||||
public async Task<Core.Auth.Entities.SsoConfig?> GetByOrganizationIdAsync(Guid organizationId)
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
@ -22,7 +24,7 @@ public class SsoConfigRepository : Repository<Core.Auth.Entities.SsoConfig, SsoC
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<Core.Auth.Entities.SsoConfig> GetByIdentifierAsync(string identifier)
|
||||
public async Task<Core.Auth.Entities.SsoConfig?> GetByIdentifierAsync(string identifier)
|
||||
{
|
||||
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
|
@ -4,6 +4,8 @@ using Bit.Infrastructure.EntityFramework.Auth.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Repositories;
|
||||
|
||||
public class SsoUserRepository : Repository<Core.Auth.Entities.SsoUser, SsoUser, long>, ISsoUserRepository
|
||||
@ -17,13 +19,13 @@ public class SsoUserRepository : Repository<Core.Auth.Entities.SsoUser, SsoUser,
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var entity = await GetDbSet(dbContext).SingleOrDefaultAsync(su => su.UserId == userId && su.OrganizationId == organizationId);
|
||||
dbContext.Entry(entity).State = EntityState.Deleted;
|
||||
await dbContext.SaveChangesAsync();
|
||||
await dbContext.SsoUsers
|
||||
.Where(su => su.UserId == userId && su.OrganizationId == organizationId)
|
||||
.ExecuteDeleteAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<Core.Auth.Entities.SsoUser> GetByUserIdOrganizationIdAsync(Guid organizationId, Guid userId)
|
||||
public async Task<Core.Auth.Entities.SsoUser?> GetByUserIdOrganizationIdAsync(Guid organizationId, Guid userId)
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
|
@ -7,6 +7,8 @@ using Bit.Infrastructure.EntityFramework.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Auth.Repositories;
|
||||
|
||||
public class WebAuthnCredentialRepository : Repository<Core.Auth.Entities.WebAuthnCredential, WebAuthnCredential, Guid>, IWebAuthnCredentialRepository
|
||||
@ -15,7 +17,7 @@ public class WebAuthnCredentialRepository : Repository<Core.Auth.Entities.WebAut
|
||||
: base(serviceScopeFactory, mapper, (context) => context.WebAuthnCredentials)
|
||||
{ }
|
||||
|
||||
public async Task<Core.Auth.Entities.WebAuthnCredential> GetByIdAsync(Guid id, Guid userId)
|
||||
public async Task<Core.Auth.Entities.WebAuthnCredential?> GetByIdAsync(Guid id, Guid userId)
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
|
Reference in New Issue
Block a user