diff options
| author | Leitwolf11 | 2026-11-06 12:57:27 +0300 |
|---|---|---|
| committer | Leitwolf11 | 2026-11-06 12:57:27 +0300 |
| commit | 53fb8b8bde857025d12655ae53857fc30226b186 (patch) | |
| tree | d0963feb1dddeedbd0980eb242dcd7e3e7c923e6 /apps/api/Accounts/PostgresAccountStore.cs | |
| parent | 8f18eba55a8980141bd7b989378cb557ae927e2e (diff) | |
| download | progmaweb-53fb8b8bde857025d12655ae53857fc30226b186.tar.gz | |
Ask for the Privacy and Security Policies at registration
progmasoft.com/privacy and progmasoft.com/security publish the two
policies in en-US, de-DE, ru-RU and he-IL, and the footer links both.
The Privacy Policy says what an account keeps and that Progmasoft keeps
an IP address for one purpose only: with a ViGet upload, to establish
where an upload that turns out to be malicious software came from and
to give it to the competent authorities. It says that no data, the IP
address included, is sold, rented or traded. The Security Policy covers
passwords, sessions, HTTPS, the ban on malicious software in ViGet and
how to report a weakness.
The registration form asks the person to accept both policies, and the
API refuses a registration without that acceptance, with a password
(acceptPolicies, a validation error of that field) or through Google:
the start of a Google registration without acceptPolicies=true goes
back to /register?google=policies-required, and the completion creates
no account unless the authentication state carries the current version.
An account keeps the version it accepted and the moment, in two new
columns that schema step 2 adds; accounts created before it keep null.
PolicyAcceptance.CurrentVersion and policyVersion on the web side name
the same date, and a web test reads the C# constant to keep them equal.
Diffstat (limited to 'apps/api/Accounts/PostgresAccountStore.cs')
| -rw-r--r-- | apps/api/Accounts/PostgresAccountStore.cs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/apps/api/Accounts/PostgresAccountStore.cs b/apps/api/Accounts/PostgresAccountStore.cs index 3a3ea82..9f93701 100644 --- a/apps/api/Accounts/PostgresAccountStore.cs +++ b/apps/api/Accounts/PostgresAccountStore.cs @@ -25,19 +25,24 @@ internal sealed class PostgresAccountStore(NpgsqlDataSource dataSource) : IAccou /// <summary>The columns of an account, in the order <see cref="ReadAccount"/> reads them.</summary> private const string AccountColumns = - "id, account_name, normalized_account_name, email, normalized_email, google_subject, password_hash, created_at"; + "id, account_name, normalized_account_name, email, normalized_email, google_subject, password_hash, created_at, " + + "policies_version, policies_accepted_at"; /// <inheritdoc/> public async ValueTask<CreateAccountResult> CreateAsync(AccountRecord account, CancellationToken cancellationToken) { - AccountRecord stored = account with { CreatedAt = ToStoredPrecision(account.CreatedAt) }; + AccountRecord stored = account with + { + CreatedAt = ToStoredPrecision(account.CreatedAt), + PoliciesAcceptedAt = account.PoliciesAcceptedAt is { } accepted ? ToStoredPrecision(accepted) : null + }; for (int attempt = 0; attempt < CreateAttempts; attempt++) { // A row that breaks a unique index is skipped instead of raising an error, so that a taken name is an // ordinary answer and the transaction log holds no failed statement for it. await using (NpgsqlCommand insert = dataSource.CreateCommand( - $"INSERT INTO accounts ({AccountColumns}) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) ON CONFLICT DO NOTHING")) + $"INSERT INTO accounts ({AccountColumns}) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) ON CONFLICT DO NOTHING")) { insert.Parameters.AddWithValue(stored.Id); insert.Parameters.AddWithValue(stored.AccountName); @@ -47,6 +52,8 @@ internal sealed class PostgresAccountStore(NpgsqlDataSource dataSource) : IAccou insert.Parameters.AddWithValue(NullableText(stored.GoogleSubject)); insert.Parameters.AddWithValue(NullableText(stored.PasswordHash)); insert.Parameters.AddWithValue(stored.CreatedAt); + insert.Parameters.AddWithValue(NullableText(stored.PoliciesVersion)); + insert.Parameters.Add(new NpgsqlParameter<DateTimeOffset?> { TypedValue = stored.PoliciesAcceptedAt }); if (await insert.ExecuteNonQueryAsync(cancellationToken) == 1) { return CreateAccountResult.Created(stored); @@ -188,7 +195,9 @@ internal sealed class PostgresAccountStore(NpgsqlDataSource dataSource) : IAccou reader.GetString(4), reader.IsDBNull(5) ? null : reader.GetString(5), reader.IsDBNull(6) ? null : reader.GetString(6), - reader.GetFieldValue<DateTimeOffset>(7)); + reader.GetFieldValue<DateTimeOffset>(7), + reader.IsDBNull(8) ? null : reader.GetString(8), + reader.IsDBNull(9) ? null : reader.GetFieldValue<DateTimeOffset>(9)); /// <summary>Converts an optional text to a parameter value.</summary> /// <param name="value">The text, or <see langword="null"/>.</param> |