feat(auth): registration mode on ConnectPage (PUBLIC_ENABLE_REGISTRATION)
Add a login/register toggle to ConnectPage backed by a new useRegisterMutation (register -> /auth/me, mirroring login). The toggle is shown only when REGISTRATION_ENABLED, resolved with the same precedence as the API base URL: runtime window.__APP_CONFIG__ > PUBLIC_ENABLE_REGISTRATION env > default true. The prod runtime-config script injects the runtime flag. The backend's ALLOW_REGISTRATION stays the real authority; this only gates the UI. EN/RU strings added. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -2,15 +2,25 @@
|
||||
# Write the SPA's runtime operator config at container start.
|
||||
#
|
||||
# The nginx base image runs every /docker-entrypoint.d/*.sh before launching
|
||||
# nginx, so this overwrites the build-time public/config.js stub with the value
|
||||
# of $PUBLIC_API_BASE_URL. That lets one prebuilt image target any backend
|
||||
# origin without rebuilding. Resolution + precedence live in src/config/env.ts.
|
||||
# nginx, so this overwrites the build-time public/config.js stub with the
|
||||
# operator's runtime config ($PUBLIC_API_BASE_URL, $PUBLIC_ENABLE_REGISTRATION).
|
||||
# That lets one prebuilt image target any backend origin and toggle sign-up
|
||||
# without rebuilding. Resolution + precedence live in src/config/env.ts.
|
||||
set -eu
|
||||
|
||||
: "${PUBLIC_API_BASE_URL:=/api/v1}"
|
||||
: "${PUBLIC_ENABLE_REGISTRATION:=true}"
|
||||
ROOT="${NGINX_HTML_ROOT:-/usr/share/nginx/html}"
|
||||
|
||||
printf 'window.__APP_CONFIG__={"apiBaseUrl":"%s"};\n' "$PUBLIC_API_BASE_URL" \
|
||||
# Anything but "false"/"0" enables the sign-up UI (mirrors parseFlag in env.ts).
|
||||
if [ "$PUBLIC_ENABLE_REGISTRATION" = "false" ] || [ "$PUBLIC_ENABLE_REGISTRATION" = "0" ]; then
|
||||
ENABLE_REGISTRATION=false
|
||||
else
|
||||
ENABLE_REGISTRATION=true
|
||||
fi
|
||||
|
||||
printf 'window.__APP_CONFIG__={"apiBaseUrl":"%s","enableRegistration":%s};\n' \
|
||||
"$PUBLIC_API_BASE_URL" "$ENABLE_REGISTRATION" \
|
||||
>"$ROOT/config.js"
|
||||
|
||||
echo "runtime-config: wrote apiBaseUrl=$PUBLIC_API_BASE_URL to $ROOT/config.js"
|
||||
echo "runtime-config: wrote apiBaseUrl=$PUBLIC_API_BASE_URL enableRegistration=$ENABLE_REGISTRATION to $ROOT/config.js"
|
||||
|
||||
Reference in New Issue
Block a user