From fa2023e5083c68dbc8b5bcbef98899a168be56e2 Mon Sep 17 00:00:00 2001 From: Syafa Hadyan Rasendriya Date: Wed, 11 Nov 2026 17:34:19 +0700 Subject: [PATCH 1/3] feat(auth): send a short email to the owner when an account is deleted --- docs/api.md | 2 +- docs/privacy.md | 4 ++-- internal/auth/auth_test.go | 21 +++++++++++++++++++++ internal/auth/service.go | 10 +++++++++- internal/mail/mail_test.go | 21 +++++++++++++++++++++ internal/mail/outbox.go | 17 +++++++++++++++++ internal/testutil/testutil.go | 19 ++++++++++++++++++- openapi.yaml | 2 +- 8 files changed, 90 insertions(+), 6 deletions(-) diff --git a/docs/api.md b/docs/api.md index f4d595a..9321935 100644 --- a/docs/api.md +++ b/docs/api.md @@ -19,7 +19,7 @@ The contract is `openapi.yaml` in the root of the repository. The job `OpenAPI l ## Deleting the account -`DELETE /v1/account` takes `{"password": "..."}` and deletes the business with everything under it, then clears the cookie and answers 204. The password is checked again so that a stolen session cannot do it alone, a wrong one answers 403 `invalid_credentials` and not 401, and a user has 5 wrong passwords an hour, shared with `DELETE /v1/gateways/{id}`. Only a wrong password uses up a try, so a call that ends in 503 `busy` or with the right password does not. After the fifth wrong one the route answers 429 `rate_limited` with `Retry-After` for every call, also with the right password. The budget is read again after the password check, so a burst of parallel calls cannot get a right password through once the budget is spent. The readings, the hourly sums and the anomalies go first in batches, and the business row goes last. A 503 `busy` can therefore come after a part of the readings was deleted, or after the whole delete when the time ran out just after the commit. The same call can be repeated until it ends with 204. A 401 on the repeat means that the session is gone, which a finished delete causes, and so does a session that ended in the meantime. The app cannot tell the two apart from the answer, so it sends the user to the sign in page. A sign in with the right password works only while the account still exists, and a failed sign in proves nothing, because a wrong password gives the same answer. It cannot be undone. +`DELETE /v1/account` takes `{"password": "..."}` and deletes the business with everything under it, then clears the cookie and answers 204. Once the delete is committed the service queues one short email to the address of the owner that says the account is gone, and an email that cannot be queued does not change the 204. The password is checked again so that a stolen session cannot do it alone, a wrong one answers 403 `invalid_credentials` and not 401, and a user has 5 wrong passwords an hour, shared with `DELETE /v1/gateways/{id}`. Only a wrong password uses up a try, so a call that ends in 503 `busy` or with the right password does not. After the fifth wrong one the route answers 429 `rate_limited` with `Retry-After` for every call, also with the right password. The budget is read again after the password check, so a burst of parallel calls cannot get a right password through once the budget is spent. The readings, the hourly sums and the anomalies go first in batches, and the business row goes last. A 503 `busy` can therefore come after a part of the readings was deleted, or after the whole delete when the time ran out just after the commit. The same call can be repeated until it ends with 204. A 401 on the repeat means that the session is gone, which a finished delete causes, and so does a session that ended in the meantime. The app cannot tell the two apart from the answer, so it sends the user to the sign in page. A sign in with the right password works only while the account still exists, and a failed sign in proves nothing, because a wrong password gives the same answer. It cannot be undone. ## Errors diff --git a/docs/privacy.md b/docs/privacy.md index 38613af..09e9e0a 100644 --- a/docs/privacy.md +++ b/docs/privacy.md @@ -27,7 +27,7 @@ The service never stores a password in clear text. A request body is not written | Where | What | When | |:---|:---|:---| -| The SMTP server that the operator configures | The email address and the link of a verification or reset mail | Every mail the service sends. When `SMTP_HOST` is empty, which production refuses, the service writes the address and the link to its log instead | +| The SMTP server that the operator configures | The email address and the link of a verification or reset mail, and the address alone for the one mail that says an account was deleted | Every mail the service sends. When `SMTP_HOST` is empty, which production refuses, the service writes the address and the link to its log instead | | Sentry | The error text, the stack, the route pattern, the status, the request id, the id of the account, the release, the environment and the server name. The text is scrubbed of emails, tokens, addresses and long numbers, but the scrubbing is best effort, so a name that sits in a database error text can pass | Only when `SENTRY_DSN` is set, and only for a failure of the service | | Grafana Cloud | The metrics, and the logs of the API containers. A log line of a request has the method, the path without its query, the status, the time it took, the client address and the error code. A route with an id in its path is logged by its pattern, such as `/v1/devices/:id`, so the id is not in the log. A line about a failed route has the type of the error and not its text | Only when the operator turns on the monitoring profile, see [Monitoring](monitoring.md). The operator sets how long Grafana Cloud keeps the logs | | The container log files of the host | The same log lines | Always. The production example keeps up to 5 files of 10 MB for each container by default (`LOG_MAX_SIZE` and `LOG_MAX_FILES`), cut by size and not by age, and Docker removes them when a container is recreated | @@ -52,7 +52,7 @@ There is no analytics script and no advertising. The service sets one cookie, th ## Deleting an account -The owner deletes the account in the app with `DELETE /v1/account`, which asks for the password again. The route first deletes the readings, the hourly sums and the anomalies of the business in batches that commit one by one. Then it deletes the business row, and every other table under the business goes with it in that one statement, because the keys cascade, see [Data model](data-model.md). That covers every table under the business, for example the user, the sessions, the gateways, the devices, the tips and the relay data. A request that stops half way leaves the account in place with part of its readings gone, and the next call goes on. It cannot be undone. The operator can still delete a business row by hand for an owner who cannot sign in. The logs, the backups, the reverse proxy of the host, Sentry, Grafana Cloud and the mail provider keep their own copies and follow their own retention. +The owner deletes the account in the app with `DELETE /v1/account`, which asks for the password again. The route first deletes the readings, the hourly sums and the anomalies of the business in batches that commit one by one. Then it deletes the business row, and every other table under the business goes with it in that one statement, because the keys cascade, see [Data model](data-model.md). That covers every table under the business, for example the user, the sessions, the gateways, the devices, the tips and the relay data. A request that stops half way leaves the account in place with part of its readings gone, and the next call goes on. It cannot be undone. When the delete is committed, the service queues one short mail to the address of the owner that says the account is gone. It keeps the address in memory for that mail only. The operator can still delete a business row by hand for an owner who cannot sign in. The logs, the backups, the reverse proxy of the host, Sentry, Grafana Cloud and the mail provider keep their own copies and follow their own retention. The owner can also remove one gateway with `DELETE /v1/gateways/{id}`, which asks for the password again in the same way. It cuts the key first, deletes the readings, the hourly sums and the anomalies of that gateway in batches, and then deletes the gateway row, and its nodes, devices, tips, relay commands and schedules go with it because the keys cascade. A request that stops half way leaves a gateway with a cut key and fewer rows, and the next call goes on. It cannot be undone. The copies that the paragraph above names keep their own retention. diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go index d894a9c..0c0fd77 100644 --- a/internal/auth/auth_test.go +++ b/internal/auth/auth_test.go @@ -1149,6 +1149,27 @@ func TestOnlyAWrongPasswordUsesUpATryToDeleteAnAccount(t *testing.T) { } } +func TestDeletingTheAccountSendsOneEmailAndAWrongPasswordSendsNone(t *testing.T) { + e := testutil.New(t) + session := e.SignUp(t, "budi@example.com") + + if r := deleteAccount(t, e, `{"password":"salah"}`, session); r.Status != http.StatusForbidden { + t.Fatalf("a wrong password answered %d", r.Status) + } + + if n := e.Mail.DeletedEmails("budi@example.com"); n != 0 { + t.Fatalf("a refused delete sent %d emails", n) + } + + if r := deleteAccount(t, e, `{"password":"kata sandi baik"}`, session); r.Status != http.StatusNoContent { + t.Fatalf("the right password answered %d %v", r.Status, r.Body) + } + + if n := e.Mail.DeletedEmails("budi@example.com"); n != 1 { + t.Fatalf("a delete sent %d emails, want 1", n) + } +} + func TestACheckOfTheLimiterCountsNothing(t *testing.T) { e := testutil.New(t) limiter := auth.NewLimiter(e.Pool) diff --git a/internal/auth/service.go b/internal/auth/service.go index 9a5fdfa..3c1af25 100644 --- a/internal/auth/service.go +++ b/internal/auth/service.go @@ -37,6 +37,7 @@ const ( type Mailer interface { Verification(to, link string) PasswordReset(to, link string) + AccountDeleted(to string) } // The limits of the account routes. A key is an address of a client or an email. @@ -356,7 +357,14 @@ func (s *Service) DeleteAccount(ctx context.Context, user *User, password string return err } - return s.store.DeleteBusiness(ctx, user.BusinessID) + if err := s.store.DeleteBusiness(ctx, user.BusinessID); err != nil { + return err + } + + // the address lives only in memory for this one email, and a mail that cannot be queued does not undo a delete that is done + s.mailer.AccountDeleted(user.Email) + + return nil } // ConfirmPassword asks the user for the password again before an action that cannot be undone, so a stolen session cannot do it alone. diff --git a/internal/mail/mail_test.go b/internal/mail/mail_test.go index 8eff368..26e3bf6 100644 --- a/internal/mail/mail_test.go +++ b/internal/mail/mail_test.go @@ -172,3 +172,24 @@ func TestAPanicOfTheSenderIsContainedAndTheMessageIsTriedAgain(t *testing.T) { q.Close(ctx) } + +func TestTheEmailOfADeletedAccountHasNoLinkAndGoesToTheAddress(t *testing.T) { + f := &flaky{sent: make(chan Message, 1)} + q := NewQueue(f, 1, 4) + + NewOutbox(q).AccountDeleted("budi@example.com") + + m := <-f.sent + if m.To != "budi@example.com" || m.Subject == "" || m.Text == "" || m.HTML == "" { + t.Fatalf("the message is %+v", m) + } + + if strings.Contains(m.Text, "http") || strings.Contains(m.HTML, "http") || strings.Contains(m.HTML, "Ketuk tautan ini u

Tautan ini berlaku 1 jam. Jika Anda tidak memintanya, abaikan email ini dan kata sandi Anda tetap sama.

`)) +const deletedHTML = `

Akun Aethera Anda dan semua data bisnis Anda sudah dihapus. Penghapusan ini tidak bisa dibatalkan.

+

Jika bukan Anda yang melakukannya, segera hubungi pengelola Aethera.

+` + // Verification queues the email with the link that verifies an address. The plain text part holds the plain URL. func (o *Outbox) Verification(to, link string) { o.send(Message{ @@ -46,6 +50,16 @@ func (o *Outbox) PasswordReset(to, link string) { }) } +// AccountDeleted queues the short email that says the account is gone, so an owner who did not do it hears about it +func (o *Outbox) AccountDeleted(to string) { + o.send(Message{ + To: to, + Subject: "Akun Aethera Anda sudah dihapus", + Text: "Akun Aethera Anda dan semua data bisnis Anda sudah dihapus. Penghapusan ini tidak bisa dibatalkan.\r\n\r\nJika bukan Anda yang melakukannya, segera hubungi pengelola Aethera.\r\n", + HTML: deletedHTML, + }) +} + func (o *Outbox) send(m Message) { if !o.queue.Enqueue(m) { slog.Warn("an email was not queued") @@ -71,3 +85,6 @@ func (Log) Verification(to, link string) { slog.Info("verification email", "to", // PasswordReset logs the link func (Log) PasswordReset(to, link string) { slog.Info("password reset email", "to", to, "link", link) } + +// AccountDeleted logs that the account is gone +func (Log) AccountDeleted(to string) { slog.Info("account deleted email", "to", to) } diff --git a/internal/testutil/testutil.go b/internal/testutil/testutil.go index 8a3c282..fd3624a 100644 --- a/internal/testutil/testutil.go +++ b/internal/testutil/testutil.go @@ -36,6 +36,7 @@ type Outbox struct { mu sync.Mutex verify map[string]string reset map[string]string + gone map[string]int } // Verification keeps the link of a verification email @@ -54,6 +55,22 @@ func (o *Outbox) PasswordReset(to, link string) { o.reset[to] = link } +// AccountDeleted counts the emails that say an account is gone +func (o *Outbox) AccountDeleted(to string) { + o.mu.Lock() + defer o.mu.Unlock() + + o.gone[to]++ +} + +// DeletedEmails returns how many emails told the address that the account is gone +func (o *Outbox) DeletedEmails(to string) int { + o.mu.Lock() + defer o.mu.Unlock() + + return o.gone[to] +} + // VerifyLink returns the last link of a verification email to the address, and whether there is one func (o *Outbox) VerifyLink(to string) (string, bool) { o.mu.Lock() @@ -108,7 +125,7 @@ func New(t *testing.T) *Env { func NewOn(t *testing.T, pool *pgxpool.Pool) *Env { t.Helper() - mail := &Outbox{verify: map[string]string{}, reset: map[string]string{}} + mail := &Outbox{verify: map[string]string{}, reset: map[string]string{}, gone: map[string]int{}} cfg := config.Config{AppEnv: config.EnvProduction, AppOrigin: Origin} diff --git a/openapi.yaml b/openapi.yaml index 973c1e7..c7b2170 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -226,7 +226,7 @@ paths: tags: [Account] operationId: deleteAccount summary: Delete the account and the business with everything under it - description: "The password is checked again, so a stolen session cannot delete the account alone. The delete takes the business and everything under it. That covers the user, the sessions, the gateways with their keys, the nodes, the devices, the readings, the anomalies, the tips, the relay commands and schedules, the rooms and the production records. It cannot be undone. The answer clears the cookie like logout. A wrong password answers 403 `invalid_credentials`, and not 401, because the session is still valid. A user has 5 wrong passwords an hour, shared with `DELETE /v1/gateways/{id}`, and only a wrong password uses up a try, so a call that ends in 503 `busy` or with the right password does not. After the fifth wrong one the route answers 429 for every call, also with the right password. The big tables go first in batches, so a 503 `busy` can come after a part of the readings was deleted, or after the whole delete when the time ran out just after the commit. The same call can be repeated until it ends with 204. A 401 on the repeat means that the session is gone, which a finished delete causes, and so does a session that ended in the meantime. The app cannot tell the two apart from the answer, so it sends the user to the sign in page. A sign in with the right password works only while the account still exists, and a failed sign in proves nothing, because a wrong password gives the same answer." + description: "The password is checked again, so a stolen session cannot delete the account alone. The delete takes the business and everything under it. That covers the user, the sessions, the gateways with their keys, the nodes, the devices, the readings, the anomalies, the tips, the relay commands and schedules, the rooms and the production records. It cannot be undone. Once the delete is committed the service queues one short email to the address of the owner that says the account is gone, and an email that cannot be queued does not change the 204. The answer clears the cookie like logout. A wrong password answers 403 `invalid_credentials`, and not 401, because the session is still valid. A user has 5 wrong passwords an hour, shared with `DELETE /v1/gateways/{id}`, and only a wrong password uses up a try, so a call that ends in 503 `busy` or with the right password does not. After the fifth wrong one the route answers 429 for every call, also with the right password. The big tables go first in batches, so a 503 `busy` can come after a part of the readings was deleted, or after the whole delete when the time ran out just after the commit. The same call can be repeated until it ends with 204. A 401 on the repeat means that the session is gone, which a finished delete causes, and so does a session that ended in the meantime. The app cannot tell the two apart from the answer, so it sends the user to the sign in page. A sign in with the right password works only while the account still exists, and a failed sign in proves nothing, because a wrong password gives the same answer." requestBody: required: true content: From 84cc7862e9e6722fffdc0d4161ad97ec3664a5dd Mon Sep 17 00:00:00 2001 From: Syafa Hadyan Rasendriya Date: Wed, 11 Nov 2026 18:34:42 +0700 Subject: [PATCH 2/3] docs(privacy): do not claim a retention time that the mail queue does not enforce --- docs/privacy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/privacy.md b/docs/privacy.md index ed0e8ea..0fbf281 100644 --- a/docs/privacy.md +++ b/docs/privacy.md @@ -52,7 +52,7 @@ There is no analytics script and no advertising. The service sets one cookie, th ## Deleting an account -The owner deletes the account in the app with `DELETE /v1/account`, which asks for the password again. The route first cuts off the hubs of the business, so they stop sending, and then deletes the readings, the hourly sums and the anomalies in batches that commit one by one. Then it deletes the business row, and every other table under the business goes with it in that one statement, because the keys cascade, see [Data model](data-model.md). That covers every table under the business, for example the user, the sessions, the gateways, the devices, the tips and the relay data. A request that stops half way leaves the account in place with part of its readings gone, and the next call goes on. It cannot be undone. When the delete call returns without an error, the service queues one short mail to the address of the owner that says the account is gone. It keeps the address in memory for that mail only, about 70 seconds at most while a failed send is tried again, and a mail that the queue drops is not sent again. The operator can still delete a business row by hand for an owner who cannot sign in. The logs, the backups, the reverse proxy of the host, Sentry, Grafana Cloud and the mail provider keep their own copies and follow their own retention. +The owner deletes the account in the app with `DELETE /v1/account`, which asks for the password again. The route first cuts off the hubs of the business, so they stop sending, and then deletes the readings, the hourly sums and the anomalies in batches that commit one by one. Then it deletes the business row, and every other table under the business goes with it in that one statement, because the keys cascade, see [Data model](data-model.md). That covers every table under the business, for example the user, the sessions, the gateways, the devices, the tips and the relay data. A request that stops half way leaves the account in place with part of its readings gone, and the next call goes on. It cannot be undone. When the delete call returns without an error, the service queues one short mail to the address of the owner that says the account is gone. It keeps the address in memory for that mail only, until the mail is sent or dropped. A failed send is tried twice more, and a mail that the queue drops is not queued a second time. The operator can still delete a business row by hand for an owner who cannot sign in. The logs, the backups, the reverse proxy of the host, Sentry, Grafana Cloud and the mail provider keep their own copies and follow their own retention. The owner can also remove one gateway with `DELETE /v1/gateways/{id}`, which asks for the password again in the same way. It cuts the key first, deletes the readings, the hourly sums and the anomalies of that gateway in batches, and then deletes the gateway row, and its nodes, devices, tips, relay commands and schedules go with it because the keys cascade. A request that stops half way leaves a gateway with a cut key and fewer rows, and the next call goes on. It cannot be undone. The copies that the paragraph above names keep their own retention. From bb239b144530c22905e0a0bc7e4a3f91d8a1bb40 Mon Sep 17 00:00:00 2001 From: Syafa Hadyan Rasendriya Date: Wed, 11 Nov 2026 18:51:05 +0700 Subject: [PATCH 3/3] docs(auth): say that the service tries to queue the deleted account email --- docs/api.md | 2 +- docs/privacy.md | 2 +- openapi.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/api.md b/docs/api.md index d315333..cea73a2 100644 --- a/docs/api.md +++ b/docs/api.md @@ -19,7 +19,7 @@ The contract is `openapi.yaml` in the root of the repository. The job `OpenAPI l ## Deleting the account -`DELETE /v1/account` takes `{"password": "..."}` and deletes the business with everything under it, then clears the cookie and answers 204. Once the delete call returns without an error, the service queues one short email to the address of the owner that says the account is gone. Only the call that deleted the business sends it, so a double click sends one. A 503 `busy` that comes after the commit sends none, and a full mail queue or a shutdown drops the email without a new try. None of this changes the 204. The password is checked again so that a stolen session cannot do it alone, a wrong one answers 403 `invalid_credentials` and not 401, and a user has 5 wrong passwords an hour, shared with `DELETE /v1/gateways/{id}`. Only a wrong password uses up a try, so a call that ends in 503 `busy` or with the right password does not. After the fifth wrong one the route answers 429 `rate_limited` with `Retry-After` for every call, also with the right password. The budget is read again after the password check, so a burst of parallel calls cannot get a right password through once the budget is spent. The hubs of the business are cut off first, so they stop sending and cannot add readings during the delete, and a call that stops half way leaves them cut. Then the readings, the hourly sums and the anomalies go in batches, and the business row goes last. A 503 `busy` can therefore come after a part of the readings was deleted, or after the whole delete when the time ran out just after the commit. The same call can be repeated until it ends with 204. A 401 on the repeat means that the session is gone, which a finished delete causes, and so does a session that ended in the meantime. The app cannot tell the two apart from the answer, so it sends the user to the sign in page. A sign in with the right password works only while the account still exists, and a failed sign in proves nothing, because a wrong password gives the same answer. It cannot be undone. +`DELETE /v1/account` takes `{"password": "..."}` and deletes the business with everything under it, then clears the cookie and answers 204. Once the delete call returns without an error, the service tries to queue one short email to the address of the owner that says the account is gone. Only the call that deleted the business sends it, so a double click sends one. A 503 `busy` that comes after the commit sends none, and a full mail queue or a shutdown drops the email without a new try. None of this changes the 204. The password is checked again so that a stolen session cannot do it alone, a wrong one answers 403 `invalid_credentials` and not 401, and a user has 5 wrong passwords an hour, shared with `DELETE /v1/gateways/{id}`. Only a wrong password uses up a try, so a call that ends in 503 `busy` or with the right password does not. After the fifth wrong one the route answers 429 `rate_limited` with `Retry-After` for every call, also with the right password. The budget is read again after the password check, so a burst of parallel calls cannot get a right password through once the budget is spent. The hubs of the business are cut off first, so they stop sending and cannot add readings during the delete, and a call that stops half way leaves them cut. Then the readings, the hourly sums and the anomalies go in batches, and the business row goes last. A 503 `busy` can therefore come after a part of the readings was deleted, or after the whole delete when the time ran out just after the commit. The same call can be repeated until it ends with 204. A 401 on the repeat means that the session is gone, which a finished delete causes, and so does a session that ended in the meantime. The app cannot tell the two apart from the answer, so it sends the user to the sign in page. A sign in with the right password works only while the account still exists, and a failed sign in proves nothing, because a wrong password gives the same answer. It cannot be undone. ## Errors diff --git a/docs/privacy.md b/docs/privacy.md index 0fbf281..564c0f3 100644 --- a/docs/privacy.md +++ b/docs/privacy.md @@ -52,7 +52,7 @@ There is no analytics script and no advertising. The service sets one cookie, th ## Deleting an account -The owner deletes the account in the app with `DELETE /v1/account`, which asks for the password again. The route first cuts off the hubs of the business, so they stop sending, and then deletes the readings, the hourly sums and the anomalies in batches that commit one by one. Then it deletes the business row, and every other table under the business goes with it in that one statement, because the keys cascade, see [Data model](data-model.md). That covers every table under the business, for example the user, the sessions, the gateways, the devices, the tips and the relay data. A request that stops half way leaves the account in place with part of its readings gone, and the next call goes on. It cannot be undone. When the delete call returns without an error, the service queues one short mail to the address of the owner that says the account is gone. It keeps the address in memory for that mail only, until the mail is sent or dropped. A failed send is tried twice more, and a mail that the queue drops is not queued a second time. The operator can still delete a business row by hand for an owner who cannot sign in. The logs, the backups, the reverse proxy of the host, Sentry, Grafana Cloud and the mail provider keep their own copies and follow their own retention. +The owner deletes the account in the app with `DELETE /v1/account`, which asks for the password again. The route first cuts off the hubs of the business, so they stop sending, and then deletes the readings, the hourly sums and the anomalies in batches that commit one by one. Then it deletes the business row, and every other table under the business goes with it in that one statement, because the keys cascade, see [Data model](data-model.md). That covers every table under the business, for example the user, the sessions, the gateways, the devices, the tips and the relay data. A request that stops half way leaves the account in place with part of its readings gone, and the next call goes on. It cannot be undone. When the delete call returns without an error, the service tries to queue one short mail to the address of the owner that says the account is gone. It keeps the address in memory for that mail only, until the mail is sent or dropped. A failed send is tried twice more, and a mail that the queue drops is not queued a second time. The operator can still delete a business row by hand for an owner who cannot sign in. The logs, the backups, the reverse proxy of the host, Sentry, Grafana Cloud and the mail provider keep their own copies and follow their own retention. The owner can also remove one gateway with `DELETE /v1/gateways/{id}`, which asks for the password again in the same way. It cuts the key first, deletes the readings, the hourly sums and the anomalies of that gateway in batches, and then deletes the gateway row, and its nodes, devices, tips, relay commands and schedules go with it because the keys cascade. A request that stops half way leaves a gateway with a cut key and fewer rows, and the next call goes on. It cannot be undone. The copies that the paragraph above names keep their own retention. diff --git a/openapi.yaml b/openapi.yaml index a0a181e..289a1f1 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -226,7 +226,7 @@ paths: tags: [Account] operationId: deleteAccount summary: Delete the account and the business with everything under it - description: "The password is checked again, so a stolen session cannot delete the account alone. The delete takes the business and everything under it. That covers the user, the sessions, the gateways with their keys, the nodes, the devices, the readings, the anomalies, the tips, the relay commands and schedules, the rooms and the production records. It cannot be undone. Once the delete call returns without an error, the service queues one short email to the address of the owner that says the account is gone. Only the call that deleted the business sends it, so a double click sends one. A 503 `busy` that comes after the commit sends none, and a full mail queue or a shutdown drops the email without a new try. None of this changes the 204. The answer clears the cookie like logout. A wrong password answers 403 `invalid_credentials`, and not 401, because the session is still valid. A user has 5 wrong passwords an hour, shared with `DELETE /v1/gateways/{id}`, and only a wrong password uses up a try, so a call that ends in 503 `busy` or with the right password does not. After the fifth wrong one the route answers 429 for every call, also with the right password. The hubs of the business are cut off first, so they stop sending and cannot add readings during the delete, and a call that stops half way leaves them cut. Then the big tables go in batches, so a 503 `busy` can come after a part of the readings was deleted, or after the whole delete when the time ran out just after the commit. The same call can be repeated until it ends with 204. A 401 on the repeat means that the session is gone, which a finished delete causes, and so does a session that ended in the meantime. The app cannot tell the two apart from the answer, so it sends the user to the sign in page. A sign in with the right password works only while the account still exists, and a failed sign in proves nothing, because a wrong password gives the same answer." + description: "The password is checked again, so a stolen session cannot delete the account alone. The delete takes the business and everything under it. That covers the user, the sessions, the gateways with their keys, the nodes, the devices, the readings, the anomalies, the tips, the relay commands and schedules, the rooms and the production records. It cannot be undone. Once the delete call returns without an error, the service tries to queue one short email to the address of the owner that says the account is gone. Only the call that deleted the business sends it, so a double click sends one. A 503 `busy` that comes after the commit sends none, and a full mail queue or a shutdown drops the email without a new try. None of this changes the 204. The answer clears the cookie like logout. A wrong password answers 403 `invalid_credentials`, and not 401, because the session is still valid. A user has 5 wrong passwords an hour, shared with `DELETE /v1/gateways/{id}`, and only a wrong password uses up a try, so a call that ends in 503 `busy` or with the right password does not. After the fifth wrong one the route answers 429 for every call, also with the right password. The hubs of the business are cut off first, so they stop sending and cannot add readings during the delete, and a call that stops half way leaves them cut. Then the big tables go in batches, so a 503 `busy` can come after a part of the readings was deleted, or after the whole delete when the time ran out just after the commit. The same call can be repeated until it ends with 204. A 401 on the repeat means that the session is gone, which a finished delete causes, and so does a session that ended in the meantime. The app cannot tell the two apart from the answer, so it sends the user to the sign in page. A sign in with the right password works only while the account still exists, and a failed sign in proves nothing, because a wrong password gives the same answer." requestBody: required: true content: