Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
12d5b6e
Remove 'UploadNewKeys' from LoginResponse
Jack-Edwards Jan 11, 2025
c9dd71a
Rename property
Jack-Edwards Jan 12, 2025
dafdd52
Add copyright header to source file
Jack-Edwards Jan 12, 2025
af6beed
Handle concurrent entries to ShowRecoveryKeyModal
Jack-Edwards Jan 12, 2025
5451b63
Only an event sent from UserKeysService will open the RecoveryKeyModal
Jack-Edwards Jan 12, 2025
3ede2f6
Reorganize UserKeysService and UserRecoveryService with EventfulUserK…
Jack-Edwards Jan 12, 2025
36b41fd
EventfulUserKeysService emits keys progress to MainLayout
Jack-Edwards Jan 12, 2025
1add12c
Revert "EventfulUserKeysService emits keys progress to MainLayout"
Jack-Edwards Jan 12, 2025
0005e2f
Reapply "EventfulUserKeysService emits keys progress to MainLayout"
Jack-Edwards Jan 12, 2025
79b4316
MainLayout should actually subscribe to the new UserKeys events
Jack-Edwards Jan 12, 2025
e05e5a7
IUserKeysService and IEventfulUserKeysService should resolve from the…
Jack-Edwards Jan 12, 2025
9b05d95
Merge pull request #752 from Crypter-File-Transfer/split-login
Jack-Edwards Jan 12, 2025
44d4615
Move AddUserContactError.cs and thus eliminate a namespace
Jack-Edwards Jan 14, 2025
1900bc5
Merge pull request #753 from Crypter-File-Transfer/update-namespace
Jack-Edwards Jan 14, 2025
bf2806d
Decouple recovery key consent handling from the login response model
Jack-Edwards Jan 14, 2025
838abb9
Merge pull request #754 from Crypter-File-Transfer/move-recovery-cons…
Jack-Edwards Jan 15, 2025
3eb356f
Bump Azure.Identity from 1.13.1 to 1.13.2
dependabot[bot] Feb 1, 2025
e2f2258
Bump MailKit from 4.9.0 to 4.10.0
dependabot[bot] Feb 1, 2025
eac49c9
Bump Npgsql and Npgsql.EntityFrameworkCore.PostgreSQL
dependabot[bot] Feb 1, 2025
70b6585
Bump Microsoft.AspNetCore.Components.WebAssembly.DevServer
dependabot[bot] Feb 1, 2025
c2bd0a4
Merge pull request #756 from Crypter-File-Transfer/dependabot/nuget/s…
Jack-Edwards Feb 9, 2025
89db94e
Merge pull request #759 from Crypter-File-Transfer/dependabot/nuget/s…
Jack-Edwards Feb 9, 2025
4316110
Merge pull request #760 from Crypter-File-Transfer/dependabot/nuget/s…
Jack-Edwards Feb 9, 2025
eb26410
Merge pull request #758 from Crypter-File-Transfer/dependabot/nuget/s…
Jack-Edwards Feb 9, 2025
01f2e92
Bump Microsoft.AspNetCore.Mvc.Testing from 9.0.0 to 9.0.1
dependabot[bot] Feb 9, 2025
306369e
Merge pull request #757 from Crypter-File-Transfer/dependabot/nuget/s…
Jack-Edwards Feb 9, 2025
fae645f
Remove [FromForm] from IFormFile to fix SwaggerGen
Jack-Edwards Feb 9, 2025
b96175a
Use AsNoTracking and switch to existence test where applicable
Feb 12, 2025
f7e27d0
Remove unused data contexts
Feb 12, 2025
f8ff510
Merge branch 'stable' of https://github.com/Crypter-File-Transfer/Cry…
Feb 12, 2025
cf8d2d4
Use AsNoTracking and switch to existence test where applicable
Feb 12, 2025
a514b7d
Remove unused data contexts
Feb 12, 2025
72f1d04
Merge branch 'feature/565-dbctx-notracking' of github.com:ibede/crypt…
Feb 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions Crypter.Core/Features/Keys/Commands/InsertKeyPairCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,17 @@ public InsertKeyPairCommandHandler(DataContext dataContext)
public async Task<Either<InsertKeyPairError, Unit>> Handle(InsertKeyPairCommand request,
CancellationToken cancellationToken)
{
UserKeyPairEntity? keyPairEntity = await _dataContext.UserKeyPairs
.FirstOrDefaultAsync(x => x.Owner == request.UserId, CancellationToken.None);
bool keyPairExists = await _dataContext.UserKeyPairs.AnyAsync(x => x.Owner == request.UserId, CancellationToken.None);

if (keyPairEntity is null)
if (!keyPairExists)
{
UserKeyPairEntity newEntity = new UserKeyPairEntity(request.UserId, request.Data.EncryptedPrivateKey,
request.Data.PublicKey, request.Data.Nonce, DateTime.UtcNow);
_dataContext.UserKeyPairs.Add(newEntity);
await _dataContext.SaveChangesAsync(CancellationToken.None);
return Unit.Default;
}

return keyPairEntity is null
? Unit.Default
: InsertKeyPairError.KeyPairAlreadyExists;
return InsertKeyPairError.KeyPairAlreadyExists;
}
}
6 changes: 3 additions & 3 deletions Crypter.Core/Features/Keys/Commands/UpsertMasterKeyCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ public async Task<Either<InsertMasterKeyError, Unit>> Handle(UpsertMasterKeyComm
_ => InsertMasterKeyError.InvalidPassword,
async _ =>
{
UserMasterKeyEntity? masterKeyEntity = await _dataContext.UserMasterKeys
.FirstOrDefaultAsync(x => x.Owner == request.UserId, CancellationToken.None);
bool masterKeyExists = await _dataContext.UserMasterKeys
.AnyAsync(x => x.Owner == request.UserId, CancellationToken.None);

if (masterKeyEntity is not null && !request.AllowReplacement)
if (masterKeyExists && !request.AllowReplacement)
{
return InsertMasterKeyError.Conflict;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public async Task<ApplicationAnalyticsReport> Handle(ApplicationAnalyticsReportQ
DateTimeOffset now = DateTimeOffset.UtcNow;
DateTimeOffset reportBegin = DateTimeOffset.UtcNow.AddDays(-request.ReportPeriodDays);

List<EventLogEntity> events = await _dataContext.EventLogs
List<EventLogEntity> events = await _dataContext.EventLogs.AsNoTracking()
.Where(eventLog => eventLog.Timestamp <= now && eventLog.Timestamp >= reportBegin)
.ToListAsync(cancellationToken);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
using Crypter.Common.Contracts.Features.Transfer;
using Crypter.Common.Enums;
using Crypter.Core.Services;
using Crypter.DataAccess;
using Hangfire;
using MediatR;

Expand All @@ -43,16 +42,13 @@ internal class FailedMultipartFileTransferAbandonEventHandler
: INotificationHandler<FailedMultipartFileTransferAbandonEvent>
{
private readonly IBackgroundJobClient _backgroundJobClient;
private readonly DataContext _dataContext;
private readonly IHangfireBackgroundService _hangfireBackgroundService;

public FailedMultipartFileTransferAbandonEventHandler(
IBackgroundJobClient backgroundJobClient,
DataContext dataContext,
IHangfireBackgroundService hangfireBackgroundService)
{
_backgroundJobClient = backgroundJobClient;
_dataContext = dataContext;
_hangfireBackgroundService = hangfireBackgroundService;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
using System.Threading.Tasks;
using Crypter.Common.Enums;
using Crypter.Core.Services;
using Crypter.DataAccess;
using Hangfire;
using MediatR;

Expand All @@ -42,16 +41,13 @@ internal class SuccessfulMultipartFileTransferAbandonEventHandler
: INotificationHandler<SuccessfulMultipartFileTransferAbandonEvent>
{
private readonly IBackgroundJobClient _backgroundJobClient;
private readonly DataContext _dataContext;
private readonly IHangfireBackgroundService _hangfireBackgroundService;

public SuccessfulMultipartFileTransferAbandonEventHandler(
IBackgroundJobClient backgroundJobClient,
DataContext dataContext,
IHangfireBackgroundService hangfireBackgroundService)
{
_backgroundJobClient = backgroundJobClient;
_dataContext = dataContext;
_hangfireBackgroundService = hangfireBackgroundService;
}

Expand Down
2 changes: 1 addition & 1 deletion Crypter.Core/Features/UserAuthentication/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Maybe<T> VerifyUserPasswordIsMigrated<T>(UserEntity user, T error)
Task<Either<T, UserEntity?>> FetchUserAsync<T>(T error)
{
return Either<T, UserEntity?>.FromRightAsync(
dataContext.Users.FirstOrDefaultAsync(x => x.Id == userId, cancellationToken),
dataContext.Users.AsNoTracking().FirstOrDefaultAsync(x => x.Id == userId, cancellationToken),
error);
}

Expand Down
Loading