Refactor recaptchaEnabled
This commit is contained in:
parent
293c42113c
commit
6e178e2eed
3 changed files with 3 additions and 7 deletions
|
@ -113,7 +113,7 @@ class Api extends events.EventTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
recaptchaEnabled() {
|
recaptchaEnabled() {
|
||||||
return !!remoteConfig.enableRecaptcha;
|
return !this.isLoggedIn() && !!remoteConfig.enableRecaptcha;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasPrivilege(lookup) {
|
hasPrivilege(lookup) {
|
||||||
|
|
|
@ -131,7 +131,7 @@ class User extends events.EventTarget {
|
||||||
if (this._password) {
|
if (this._password) {
|
||||||
detail.password = this._password;
|
detail.password = this._password;
|
||||||
}
|
}
|
||||||
if (!api.isLoggedIn()) {
|
if (api.recaptchaEnabled) {
|
||||||
detail.recaptchaToken = recaptchaToken;
|
detail.recaptchaToken = recaptchaToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,17 +9,13 @@ const template = views.getTemplate("user-registration");
|
||||||
class RegistrationView extends events.EventTarget {
|
class RegistrationView extends events.EventTarget {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
// Show the recaptcha only for anonymous users.
|
|
||||||
const showRecaptcha = (!api.isLoggedIn() && api.recaptchaEnabled());
|
|
||||||
|
|
||||||
this._hostNode = document.getElementById("content-holder");
|
this._hostNode = document.getElementById("content-holder");
|
||||||
views.replaceContent(
|
views.replaceContent(
|
||||||
this._hostNode,
|
this._hostNode,
|
||||||
template({
|
template({
|
||||||
userNamePattern: api.getUserNameRegex(),
|
userNamePattern: api.getUserNameRegex(),
|
||||||
passwordPattern: api.getPasswordRegex(),
|
passwordPattern: api.getPasswordRegex(),
|
||||||
enableRecaptcha: showRecaptcha,
|
enableRecaptcha: api.recaptchaEnabled(),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
views.syncScrollPosition();
|
views.syncScrollPosition();
|
||||||
|
|
Reference in a new issue