Add recaptcha site key config

This commit is contained in:
Jesse 2020-07-08 04:56:23 -04:00
parent b771dd6791
commit 293c42113c
No known key found for this signature in database
GPG key ID: 1A8AB3257B32D91F
4 changed files with 8 additions and 3 deletions

View file

@ -100,6 +100,10 @@ class Api extends events.EventTarget {
return remoteConfig.contactEmail;
}
getRecaptchaSiteKey() {
return remoteConfig.recaptchaSiteKey;
}
canSendMails() {
return !!remoteConfig.canSendMails;
}

View file

@ -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(),
});
}

View file

@ -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

View file

@ -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"):