From 293c42113c3fa64ade813f7d2a6815b7564be124 Mon Sep 17 00:00:00 2001 From: Jesse <2302541+Kangaroux@users.noreply.github.com> Date: Wed, 8 Jul 2020 04:56:23 -0400 Subject: [PATCH] Add recaptcha site key config --- client/js/api.js | 4 ++++ client/js/views/registration_view.js | 3 +-- server/config.yaml.dist | 3 ++- server/szurubooru/api/info_api.py | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/client/js/api.js b/client/js/api.js index a6bec97f..21ec235d 100644 --- a/client/js/api.js +++ b/client/js/api.js @@ -100,6 +100,10 @@ class Api extends events.EventTarget { return remoteConfig.contactEmail; } + getRecaptchaSiteKey() { + return remoteConfig.recaptchaSiteKey; + } + canSendMails() { return !!remoteConfig.canSendMails; } diff --git a/client/js/views/registration_view.js b/client/js/views/registration_view.js index 4e29a07d..4870c871 100644 --- a/client/js/views/registration_view.js +++ b/client/js/views/registration_view.js @@ -5,7 +5,6 @@ const api = require("../api.js"); const views = require("../util/views.js"); const template = views.getTemplate("user-registration"); -const RECAPTCHA_SITE_KEY = "site key"; class RegistrationView extends events.EventTarget { constructor() { @@ -35,7 +34,7 @@ class RegistrationView extends events.EventTarget { renderRecaptcha() { grecaptcha.render(this._recaptchaNode, { "callback": this.setRecaptchaToken, - "sitekey": RECAPTCHA_SITE_KEY, + "sitekey": api.getRecaptchaSiteKey(), }); } diff --git a/server/config.yaml.dist b/server/config.yaml.dist index 5758922e..b28710ec 100644 --- a/server/config.yaml.dist +++ b/server/config.yaml.dist @@ -10,7 +10,8 @@ secret: change # Whether solving a captcha is required for registration for anonymous users. enable_recaptcha: no - +# The reCAPTCHA site key. +recaptcha_site_key: change # A reCAPTCHA v2 secret token. # https://developers.google.com/recaptcha/intro # https://developers.google.com/recaptcha/docs/display diff --git a/server/szurubooru/api/info_api.py b/server/szurubooru/api/info_api.py index 5574270c..667b2c5d 100644 --- a/server/szurubooru/api/info_api.py +++ b/server/szurubooru/api/info_api.py @@ -50,6 +50,7 @@ def get_info(ctx: rest.Context, _params: Dict[str, str] = {}) -> rest.Response: config.config["privileges"] ), "enableRecaptcha": config.config["enable_recaptcha"], + "recaptchaSiteKey": config.config["recaptcha_site_key"], }, } if auth.has_privilege(ctx.user, "posts:view:featured"):