turnstile siteKey added with a env var
This commit is contained in:
parent
3e56f6db41
commit
a904bd7951
|
|
@ -12,6 +12,8 @@ FROM nginx:1.27-alpine
|
|||
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY --from=builder /app/dist/humainFlow-gui-a21/browser /usr/share/nginx/html
|
||||
COPY docker/40-runtime-config.sh /docker-entrypoint.d/40-runtime-config.sh
|
||||
RUN chmod +x /docker-entrypoint.d/40-runtime-config.sh
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
cat >/usr/share/nginx/html/runtime-config.js <<EOF
|
||||
window.__runtimeConfig = {
|
||||
turnstileSiteKey: "${TURNSTILE_SITE_KEY:-}"
|
||||
};
|
||||
EOF
|
||||
|
|
@ -74,7 +74,6 @@
|
|||
}
|
||||
|
||||
.admin-shell__back-link {
|
||||
margin-top: auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@ function hasValidPasswordComplexity(value: string): boolean {
|
|||
|
||||
declare global {
|
||||
interface Window {
|
||||
__runtimeConfig?: {
|
||||
turnstileSiteKey?: string;
|
||||
};
|
||||
turnstile?: {
|
||||
render: (container: string | HTMLElement, options: Record<string, unknown>) => string;
|
||||
remove: (widgetId: string) => void;
|
||||
|
|
@ -50,7 +53,7 @@ export class Signup extends FormUtility implements AfterViewInit, OnDestroy {
|
|||
isRegistering = signal(false);
|
||||
captchaToken = signal<string | null>(null);
|
||||
captchaLoading = signal(false);
|
||||
captchaEnabled = !!String(environment.turnstileSiteKey ?? '').trim();
|
||||
captchaEnabled = environment.turnstileEnabled;
|
||||
private captchaWidgetId: string | null = null;
|
||||
|
||||
constructor() {
|
||||
|
|
@ -158,7 +161,7 @@ export class Signup extends FormUtility implements AfterViewInit, OnDestroy {
|
|||
}
|
||||
|
||||
private async mountCaptcha() {
|
||||
const siteKey = String(environment.turnstileSiteKey ?? '').trim();
|
||||
const siteKey = this.turnstileSiteKey();
|
||||
const container = this.captchaContainer()?.nativeElement;
|
||||
if (!siteKey || !container) return;
|
||||
|
||||
|
|
@ -227,4 +230,8 @@ export class Signup extends FormUtility implements AfterViewInit, OnDestroy {
|
|||
window.turnstile.reset(this.captchaWidgetId);
|
||||
}
|
||||
}
|
||||
|
||||
private turnstileSiteKey(): string {
|
||||
return String(window.__runtimeConfig?.turnstileSiteKey ?? '').trim();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export const environment = {
|
|||
apiUrl: 'http://localhost:8080',
|
||||
assistantEnabled: false,
|
||||
tourModeAlwaysOn: true,
|
||||
turnstileSiteKey: '',
|
||||
turnstileEnabled: false,
|
||||
authorizationCallService: AuthorizationCallFakeService, // Assign the appropriate service here
|
||||
assistantCallService: AssistantCallServiceFake,
|
||||
flowsCallService: FlowsCallServiceFake,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export const environment = {
|
|||
apiUrl: 'http://localhost:8080',
|
||||
assistantEnabled: true,
|
||||
tourModeAlwaysOn: false,
|
||||
turnstileSiteKey: '',
|
||||
turnstileEnabled: false,
|
||||
assistantCallService: AssistantCallService,
|
||||
authorizationCallService: AuthorizationCallService,
|
||||
flowsCallService: FlowsCallService,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export const environment = {
|
|||
production: true,
|
||||
assistantEnabled: false,
|
||||
tourModeAlwaysOn: false,
|
||||
turnstileSiteKey: '',
|
||||
turnstileEnabled: true,
|
||||
authorizationCallService: AuthorizationCallService,
|
||||
assistantCallService: AssistantCallService,
|
||||
flowsCallService: FlowsCallService,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
<base href="/">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||
<script src="/runtime-config.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
declare global {
|
||||
interface Window {
|
||||
__runtimeConfig?: {
|
||||
turnstileSiteKey?: string;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
Loading…
Reference in New Issue