Skip to content

feat: join get_base_config and get_public_config api - #714

Merged
yaroslav8765 merged 9 commits into
mainfrom
join_get_publik_base_config
Aug 12, 2026
Merged

feat: join get_base_config and get_public_config api#714
yaroslav8765 merged 9 commits into
mainfrom
join_get_publik_base_config

Conversation

@yaroslav8765

Copy link
Copy Markdown
Contributor

AdminForth/1888/https-claude.aicodeartifact7d7

AdminForth/1888/https-claude.aicodeartifact7d7
This reverts commit 3430200.

AdminForth/1877/login-page-improvements
… updated backend get_config logic

AdminForth/1877/login-page-improvements
AdminForth/1877/login-page-improvements

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_config endpoint 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.

Comment thread adminforth/spa/src/stores/core.ts
Comment thread adminforth/spa/src/utils/utils.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 processAuthorizeCallbacks method is now dead code. The authorize flow was moved into AdminForthAuth.authorizeByCookies / runAdminUserAuthorizeHooks, and the authorize middleware no longer calls this method. A repo-wide search finds no remaining callers, so this method (and the toReturn mutation pattern it relies on) can be removed to avoid leaving an unused, diverging copy of the hook logic (note it uses if (!allowed || error) whereas authorizeByCookies uses if (!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
@yaroslav8765
yaroslav8765 merged commit d1862d9 into main Aug 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants