diff options
| author | Leitwolf | 2026-10-29 13:08:07 +0300 |
|---|---|---|
| committer | GitHub | 2026-10-29 13:08:07 +0300 |
| commit | 4b414909ac818a9178d72ffa6e1c396d5fa27a59 (patch) | |
| tree | 9801dc805a397052264cc5bc0a6c56cf870b179a /apps/api/Accounts | |
| parent | f22418235a0a87bc05b3bf9079fcdefba002d3b2 (diff) | |
| parent | 285e1024da64234b30b0fa425ffd6bf348119db4 (diff) | |
| download | progmaweb-4b414909ac818a9178d72ffa6e1c396d5fa27a59.tar.gz | |
Merge pull request #47 from Progmasoft/feature/viget-tazel-plugins
Add the Tazel plugin catalog of ViGet and open the Gradle catalog
Diffstat (limited to 'apps/api/Accounts')
| -rw-r--r-- | apps/api/Accounts/IAccountStore.cs | 7 | ||||
| -rw-r--r-- | apps/api/Accounts/InMemoryAccountStore.cs | 13 | ||||
| -rw-r--r-- | apps/api/Accounts/PostgresAccountStore.cs | 6 |
3 files changed, 26 insertions, 0 deletions
diff --git a/apps/api/Accounts/IAccountStore.cs b/apps/api/Accounts/IAccountStore.cs index efb7c5b..ccb4c02 100644 --- a/apps/api/Accounts/IAccountStore.cs +++ b/apps/api/Accounts/IAccountStore.cs @@ -31,6 +31,13 @@ internal interface IAccountStore /// <param name="cancellationToken">Cancels the operation.</param> /// <returns>The account, or <see langword="null"/> when it does not exist.</returns> ValueTask<AccountRecord?> FindByIdAsync(Guid id, CancellationToken cancellationToken); + /// <summary>Finds an account by its normalized name.</summary> + /// <param name="normalizedAccountName"> + /// Upper-case account name, as <see cref="AccountNamePolicy.NormalizeForLookup"/> produces it. + /// </param> + /// <param name="cancellationToken">Cancels the operation.</param> + /// <returns>The account, or <see langword="null"/> when no account has this name.</returns> + ValueTask<AccountRecord?> FindByAccountNameAsync(string normalizedAccountName, CancellationToken cancellationToken); /// <summary>Stores a session, replacing one with the same token digest.</summary> /// <param name="session">The session to store.</param> /// <param name="cancellationToken">Cancels the operation.</param> diff --git a/apps/api/Accounts/InMemoryAccountStore.cs b/apps/api/Accounts/InMemoryAccountStore.cs index 8606443..2f9af9d 100644 --- a/apps/api/Accounts/InMemoryAccountStore.cs +++ b/apps/api/Accounts/InMemoryAccountStore.cs @@ -82,6 +82,19 @@ internal sealed class InMemoryAccountStore : IAccountStore } /// <inheritdoc/> + public ValueTask<AccountRecord?> FindByAccountNameAsync( + string normalizedAccountName, + CancellationToken cancellationToken) + { + cancellationToken.ThrowIfCancellationRequested(); + lock (gate) + { + return ValueTask.FromResult( + accountIdsByName.TryGetValue(normalizedAccountName, out Guid id) ? accountsById[id] : null); + } + } + + /// <inheritdoc/> public ValueTask<AccountRecord?> FindByIdAsync(Guid id, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); diff --git a/apps/api/Accounts/PostgresAccountStore.cs b/apps/api/Accounts/PostgresAccountStore.cs index a0e3444..3a3ea82 100644 --- a/apps/api/Accounts/PostgresAccountStore.cs +++ b/apps/api/Accounts/PostgresAccountStore.cs @@ -98,6 +98,12 @@ internal sealed class PostgresAccountStore(NpgsqlDataSource dataSource) : IAccou FindAccountAsync("google_subject", googleSubject, cancellationToken); /// <inheritdoc/> + public ValueTask<AccountRecord?> FindByAccountNameAsync( + string normalizedAccountName, + CancellationToken cancellationToken) => + FindAccountAsync("normalized_account_name", normalizedAccountName, cancellationToken); + + /// <inheritdoc/> public ValueTask<AccountRecord?> FindByIdAsync(Guid id, CancellationToken cancellationToken) => FindAccountAsync("id", id, cancellationToken); |