mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 03:59:21 +03:00
reCaptcha at admin login
https://github.com/the-djmaze/snappymail/issues/222#issuecomment-1036211212
This commit is contained in:
parent
fecc9f96eb
commit
2fea7b92e1
4 changed files with 25 additions and 23 deletions
|
|
@ -2,13 +2,16 @@
|
|||
(rl => {
|
||||
|
||||
rl && addEventListener('rl-view-model', e => {
|
||||
if (e.detail && 'Login' === e.detail.viewModelTemplateID
|
||||
const id = e.detail.viewModelTemplateID;
|
||||
if (e.detail && ('AdminLogin' === id || 'Login' === id)
|
||||
&& rl.pluginSettingsGet('recaptcha', 'show_captcha_on_login')) {
|
||||
let
|
||||
nId = null,
|
||||
script;
|
||||
|
||||
const
|
||||
mode = 'Login' === id ? 'user' : 'admin',
|
||||
|
||||
doc = document,
|
||||
|
||||
container = e.detail.viewModelDom.querySelector('#plugin-Login-BottomControlGroup'),
|
||||
|
|
@ -42,15 +45,15 @@
|
|||
|
||||
StartRecaptcha();
|
||||
|
||||
addEventListener('sm-user-login', e => {
|
||||
addEventListener(`sm-${mode}-login`, e => {
|
||||
if (null !== nId && window.grecaptcha) {
|
||||
e.detail.set('RecaptchaResponse', window.grecaptcha.getResponse(nId));
|
||||
} else {
|
||||
e.preventDefault()
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
addEventListener('sm-user-login-response', e => {
|
||||
addEventListener(`sm-${mode}-login-response`, e => {
|
||||
if (e.detail.error) {
|
||||
if (null !== nId && window.grecaptcha) {
|
||||
window.grecaptcha.reset(nId);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue