feat: join get_base_config and get_public_config api - #714
Conversation
AdminForth/1888/https-claude.aicodeartifact7d7
This reverts commit 3430200. AdminForth/1877/login-page-improvements
AdminForth/1877/login-page-improvements
… updated backend get_config logic AdminForth/1877/login-page-improvements
AdminForth/1877/login-page-improvements
There was a problem hiding this comment.
Pull request overview
This PR consolidates the frontend “public config” and authenticated “base config” fetches into a single /get_config API that returns a public-only config shape for anonymous users and the full config + menu/resources for authenticated users, enabling anonymous-rendered custom pages.
Changes:
- Introduces
/get_configendpoint returning a discriminated union response (loggedIn: true|false) and removes the old split endpoints. - Updates SPA initialization and core store to fetch the unified config and support anonymous rendering for custom layouts.
- Adds a dev-demo public custom page to validate anonymous rendering with
sidebarAndHeader: 'none'.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| dev-demo/index.ts | Registers a new custom public page route in the demo config. |
| dev-demo/custom/PublicPage.vue | Adds a demo page that renders without auth and displays public vs private config availability. |
| adminforth/types/Common.ts | Adds public-config and unified /get_config response types (anonymous vs authorized). |
| adminforth/spa/src/utils/utils.ts | Extracts 401 handling into handleNotAuthorized() for reuse. |
| adminforth/spa/src/stores/core.ts | Replaces /get_base_config usage with fetchConfig() against /get_config. |
| adminforth/spa/src/App.vue | Switches initial SPA bootstrapping to load unified config and only force-login on default layouts. |
| adminforth/modules/restApi.ts | Implements /get_config combining public config and authenticated base config behavior. |
Suppressed comments (2)
adminforth/modules/restApi.ts:984
- This endpoint already computed userResource earlier, but it does another resources.find() for the same usersResourceId. Reuse userResource to avoid duplicate work and reduce the chance of the two lookups diverging in future refactors.
const usersResource = this.adminforth.config.resources.find((res) => res.resourceId === this.adminforth.config.auth.usersResourceId);
const defaultUserExists = await this.adminforth.resource(usersResource.resourceId).get(Filters.EQ(usernameField, 'adminforth')) ? true : false;
adminforth/modules/restApi.ts:903
- Variable name public_config uses snake_case, while the surrounding codebase uses camelCase (e.g., userResource, loggedInPart). Renaming to publicConfig would improve consistency and readability.
This issue also appears on line 983 of the same file.
const public_config = {
brandName: this.adminforth.config.customization.brandName,
usernameFieldName: usernameColumn.label,
loginBackgroundImage: this.adminforth.config.auth.loginBackgroundImage,
loginBackgroundPosition: this.adminforth.config.auth.loginBackgroundPosition,
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…gForFrontend AdminForth/1877/login-page-improvements
…nd basic express auth wrapper AdminForth/1877/login-page-improvements
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.
Suppressed comments (1)
adminforth/servers/express.ts:362
- This
processAuthorizeCallbacksmethod is now dead code. The authorize flow was moved intoAdminForthAuth.authorizeByCookies/runAdminUserAuthorizeHooks, and theauthorizemiddleware no longer calls this method. A repo-wide search finds no remaining callers, so this method (and thetoReturnmutation pattern it relies on) can be removed to avoid leaving an unused, diverging copy of the hook logic (note it usesif (!allowed || error)whereasauthorizeByCookiesusesif (!allowed)).
async processAuthorizeCallbacks(adminUser: AdminUser, toReturn: { error?: string, allowed: boolean }, response: Response, extra: HttpExtra) {
const { allowed, error } = await this.adminforth.auth.runAdminUserAuthorizeHooks(adminUser, response as any, extra);
if (!allowed || error) {
// delete all items from toReturn and add these:
toReturn.allowed = allowed;
toReturn.error = error;
}
}
AdminForth/1877/login-page-improvements
AdminForth/1888/https-claude.aicodeartifact7d7