[PR #825] [MERGED] refactor(apiv1): accounts api #809

Closed
opened 2026-02-25 23:35:32 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-shiori/shiori/pull/825
Author: @fmartingr
Created: 1/27/2024
Status: Merged
Merged: 2/22/2025
Merged by: @fmartingr

Base: masterHead: fmartingr/issue657


📝 Commits (10+)

  • 463f16f list account and create account
  • 795b39c deleteaccount (wip)
  • 14e54a4 Merge remote-tracking branch 'origin/master' into fmartingr/issue657
  • da169fe remove old accounts code
  • 8c02f9d fix from merge
  • e88bfe3 remove serve method from makefile
  • 21d3066 ListAccounts, password hash on domain
  • 56f441e make lint
  • 0835804 more permissive assertion
  • 744b2d5 Merge remote-tracking branch 'origin/master' into fmartingr/issue657

📊 Changes

67 files changed (+3816 additions, -1038 deletions)

View changed files

.githooks/pre-commit (+0 -11)
📝 .github/workflows/_e2e.yml (+13 -0)
📝 .gitignore (+2 -1)
📝 Makefile (+3 -3)
📝 docs/swagger/docs.go (+174 -4)
📝 docs/swagger/swagger.json (+174 -4)
📝 docs/swagger/swagger.yaml (+115 -4)
📝 e2e/e2eutil/containers.go (+6 -6)
e2e/playwright/accounts_test.go (+412 -0)
e2e/playwright/auth_test.go (+159 -0)
e2e/playwright/playwright_test.go (+7 -0)
e2e/playwright/reporter.go (+158 -0)
e2e/playwright/testhelper.go (+208 -0)
e2e/server/auth_test.go (+34 -0)
📝 go.mod (+8 -6)
📝 go.sum (+19 -145)
📝 internal/cmd/root.go (+6 -5)
📝 internal/core/core.go (+3 -1)
📝 internal/database/database.go (+29 -14)
📝 internal/database/database_test.go (+197 -74)

...and 47 more files

📄 Description

  • Refactor Accounts API to API v1
  • Renamed current AccountsDomain to AuthDomain to handle authentication logic in a separate layer.
  • Adds AccountsDomain which contains logic related to managing Accounts and is the layer that communicates with teh database.
  • New AccountDTO object. Account is the exact database representation of the row, AccountDTO is the object we can transfer around in the rest of the code with more fields, helper methods, etc. Is also the object used in creates/updates for the Accounts with included validation.
    • Changed the Account usages around the code to be AccountDTO.
  • Database interface changes:
    • Added new Database.ListAccounts (formerly Database.GetAccounts). Using List* to better differentiate between the method that return one account and the one that return many.
      • Accepts new ListAccountOptions to filter by keyword, username and owner. Also allows retrieving the password field which is disabled by default.
    • DeleteAccount replaces DeleteAccounts. Now only deletes one account, iteration logic moved to the AccountsDomain.
    • SaveAccount is not called CreateAccount
  • New middleware: AdminRequired
  • Changed /api/v1/auth/account to allow updating the entire user data, not only the settings. This should be backwards compatible.
  • Added model.Ptr helper that return an object as a pointer of itself
  • Added ValidationError error type to return directly from domains and have details available to expose to the API.
  • Testutil additions: NewAdminUser and options.WithAuthToken to avoid boilerplate in tests.
  • e2e tests: Added plywright to perform real e2e testing on a browser, added tests to check that the current account workflows work (login, logout, add user, remove user, change password, change password for self)

Closes #657


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-shiori/shiori/pull/825 **Author:** [@fmartingr](https://github.com/fmartingr) **Created:** 1/27/2024 **Status:** ✅ Merged **Merged:** 2/22/2025 **Merged by:** [@fmartingr](https://github.com/fmartingr) **Base:** `master` ← **Head:** `fmartingr/issue657` --- ### 📝 Commits (10+) - [`463f16f`](https://github.com/go-shiori/shiori/commit/463f16f361ad27f5aa83530c11d0fb2d53d2fa02) list account and create account - [`795b39c`](https://github.com/go-shiori/shiori/commit/795b39c9863ddb38cdbc45df0272faae0da48db1) deleteaccount (wip) - [`14e54a4`](https://github.com/go-shiori/shiori/commit/14e54a48606022137c0f1534867174b3202f0f46) Merge remote-tracking branch 'origin/master' into fmartingr/issue657 - [`da169fe`](https://github.com/go-shiori/shiori/commit/da169fe80a06ac65031456d9aa05400561d874f1) remove old accounts code - [`8c02f9d`](https://github.com/go-shiori/shiori/commit/8c02f9db8730910c4ee11986fd06269d0fd25cb0) fix from merge - [`e88bfe3`](https://github.com/go-shiori/shiori/commit/e88bfe3c0b3c91b183f59a1ac897a728a8fbeb72) remove serve method from makefile - [`21d3066`](https://github.com/go-shiori/shiori/commit/21d306641d686d66d7c4740fa579b364ad99977a) ListAccounts, password hash on domain - [`56f441e`](https://github.com/go-shiori/shiori/commit/56f441e75a06890d584793d281219d7244144be5) make lint - [`0835804`](https://github.com/go-shiori/shiori/commit/0835804f63272901141c5fc094f7041d663bad07) more permissive assertion - [`744b2d5`](https://github.com/go-shiori/shiori/commit/744b2d54516769efe0fde964120c9f799cc2effd) Merge remote-tracking branch 'origin/master' into fmartingr/issue657 ### 📊 Changes **67 files changed** (+3816 additions, -1038 deletions) <details> <summary>View changed files</summary> ➖ `.githooks/pre-commit` (+0 -11) 📝 `.github/workflows/_e2e.yml` (+13 -0) 📝 `.gitignore` (+2 -1) 📝 `Makefile` (+3 -3) 📝 `docs/swagger/docs.go` (+174 -4) 📝 `docs/swagger/swagger.json` (+174 -4) 📝 `docs/swagger/swagger.yaml` (+115 -4) 📝 `e2e/e2eutil/containers.go` (+6 -6) ➕ `e2e/playwright/accounts_test.go` (+412 -0) ➕ `e2e/playwright/auth_test.go` (+159 -0) ➕ `e2e/playwright/playwright_test.go` (+7 -0) ➕ `e2e/playwright/reporter.go` (+158 -0) ➕ `e2e/playwright/testhelper.go` (+208 -0) ➕ `e2e/server/auth_test.go` (+34 -0) 📝 `go.mod` (+8 -6) 📝 `go.sum` (+19 -145) 📝 `internal/cmd/root.go` (+6 -5) 📝 `internal/core/core.go` (+3 -1) 📝 `internal/database/database.go` (+29 -14) 📝 `internal/database/database_test.go` (+197 -74) _...and 47 more files_ </details> ### 📄 Description - Refactor Accounts API to API v1 - Renamed current `AccountsDomain` to `AuthDomain` to handle authentication logic in a separate layer. - Adds `AccountsDomain` which contains logic related to managing Accounts and is the layer that communicates with teh database. - New `AccountDTO` object. `Account` is the exact database representation of the row, `AccountDTO` is the object we can transfer around in the rest of the code with more fields, helper methods, etc. Is also the object used in creates/updates for the Accounts with included validation. - Changed the `Account` usages around the code to be `AccountDTO`. - `Database` interface changes: - Added new `Database.ListAccounts` (formerly `Database.GetAccounts`). Using `List*` to better differentiate between the method that return one account and the one that return many. - Accepts new `ListAccountOptions` to filter by keyword, username and owner. Also allows retrieving the password field which **is disabled by default**. - `DeleteAccount` replaces `DeleteAccounts`. Now only deletes one account, iteration logic moved to the `AccountsDomain`. - `SaveAccount` is not called `CreateAccount` - New middleware: `AdminRequired` - Changed `/api/v1/auth/account` to allow updating the entire user data, not only the settings. This should be backwards compatible. - Added `model.Ptr` helper that return an object as a pointer of itself - Added `ValidationError` error type to return directly from domains and have details available to expose to the API. - Testutil additions: `NewAdminUser` and `options.WithAuthToken` to avoid boilerplate in tests. - e2e tests: Added plywright to perform real e2e testing on a browser, added tests to check that the current account workflows work (login, logout, add user, remove user, change password, change password for self) Closes #657 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-25 23:35:32 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/shiori#809
No description provided.