Add recaptcha site key config
This commit is contained in:
parent
b771dd6791
commit
293c42113c
4 changed files with 8 additions and 3 deletions
|
@ -100,6 +100,10 @@ class Api extends events.EventTarget {
|
||||||
return remoteConfig.contactEmail;
|
return remoteConfig.contactEmail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getRecaptchaSiteKey() {
|
||||||
|
return remoteConfig.recaptchaSiteKey;
|
||||||
|
}
|
||||||
|
|
||||||
canSendMails() {
|
canSendMails() {
|
||||||
return !!remoteConfig.canSendMails;
|
return !!remoteConfig.canSendMails;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ const api = require("../api.js");
|
||||||
const views = require("../util/views.js");
|
const views = require("../util/views.js");
|
||||||
|
|
||||||
const template = views.getTemplate("user-registration");
|
const template = views.getTemplate("user-registration");
|
||||||
const RECAPTCHA_SITE_KEY = "site key";
|
|
||||||
|
|
||||||
class RegistrationView extends events.EventTarget {
|
class RegistrationView extends events.EventTarget {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -35,7 +34,7 @@ class RegistrationView extends events.EventTarget {
|
||||||
renderRecaptcha() {
|
renderRecaptcha() {
|
||||||
grecaptcha.render(this._recaptchaNode, {
|
grecaptcha.render(this._recaptchaNode, {
|
||||||
"callback": this.setRecaptchaToken,
|
"callback": this.setRecaptchaToken,
|
||||||
"sitekey": RECAPTCHA_SITE_KEY,
|
"sitekey": api.getRecaptchaSiteKey(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,8 @@ secret: change
|
||||||
|
|
||||||
# Whether solving a captcha is required for registration for anonymous users.
|
# Whether solving a captcha is required for registration for anonymous users.
|
||||||
enable_recaptcha: no
|
enable_recaptcha: no
|
||||||
|
# The reCAPTCHA site key.
|
||||||
|
recaptcha_site_key: change
|
||||||
# A reCAPTCHA v2 secret token.
|
# A reCAPTCHA v2 secret token.
|
||||||
# https://developers.google.com/recaptcha/intro
|
# https://developers.google.com/recaptcha/intro
|
||||||
# https://developers.google.com/recaptcha/docs/display
|
# https://developers.google.com/recaptcha/docs/display
|
||||||
|
|
|
@ -50,6 +50,7 @@ def get_info(ctx: rest.Context, _params: Dict[str, str] = {}) -> rest.Response:
|
||||||
config.config["privileges"]
|
config.config["privileges"]
|
||||||
),
|
),
|
||||||
"enableRecaptcha": config.config["enable_recaptcha"],
|
"enableRecaptcha": config.config["enable_recaptcha"],
|
||||||
|
"recaptchaSiteKey": config.config["recaptcha_site_key"],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if auth.has_privilege(ctx.user, "posts:view:featured"):
|
if auth.has_privilege(ctx.user, "posts:view:featured"):
|
||||||
|
|
Reference in a new issue