-
-
Notifications
You must be signed in to change notification settings - Fork 699
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] Adding recaptcha validation in login, password reset , signup, …
…widget form website
- Loading branch information
1 parent
b234960
commit 5425df3
Showing
13 changed files
with
174 additions
and
29 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
setup/website_recaptcha_v2_form/odoo/addons/website_recaptcha_v2_form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../website_recaptcha_v2_form |
File renamed without changes.
1 change: 0 additions & 1 deletion
1
setup/website_recaptcha_v2_login/odoo/addons/website_recaptcha_v2_login
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
div.s_website_form_recaptcha_v2 { | ||
> div.g-recaptcha { | ||
margin-left: 18% !important; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
website_recaptcha_v2_form/static/src/snippets/s_website_form/options.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
odoo.define("website_recaptcha_v2_form.form_editor", function (require) { | ||
"use strict"; | ||
|
||
var options = require("web_editor.snippets.options"); | ||
const core = require("web.core"); | ||
const rpc = require("web.rpc"); | ||
const qweb = core.qweb; | ||
require("website.form_editor"); | ||
|
||
options.registry.WebsiteFormEditor.include({ | ||
willStart: async function () { | ||
var res = this._super(...arguments); | ||
this.recaptcha_site_key = await rpc.query({ | ||
model: "website", | ||
method: "get_recaptcha_v2_site_key", | ||
}); | ||
return res; | ||
}, | ||
toggleRecaptchaV2: async function () { | ||
const recaptchaV2 = this.$target[0].querySelector( | ||
".s_website_form_recaptcha_v2" | ||
); | ||
if (recaptchaV2) { | ||
recaptchaV2.remove(); | ||
} else { | ||
const legal = qweb.render("website_recaptcha_v2_form.recaptcha_v2", { | ||
recaptcha_site_key: this.recaptcha_site_key, | ||
}); | ||
this.$target.find(".s_website_form_submit").before(legal); | ||
} | ||
}, | ||
_computeWidgetState: function (methodName, params) { | ||
switch (methodName) { | ||
case "toggleRecaptchaV2": | ||
return ( | ||
!this.$target[0].querySelector( | ||
".s_website_form_recaptcha_v2" | ||
) || "" | ||
); | ||
} | ||
return this._super(...arguments); | ||
}, | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
website_recaptcha_v2_form/static/src/xml/website_form_editor.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates xml:space="preserve"> | ||
|
||
<t t-name="website_recaptcha_v2_form.recaptcha_v2"> | ||
<div class="col-12 s_website_form_recaptcha_v2" data-name="Recaptcha v2 Legal"> | ||
<div class="g-recaptcha" t-att-data-sitekey="recaptcha_site_key" /> | ||
<script src="https://www.recaptcha.net/recaptcha/api.js" async="1" /> | ||
</div> | ||
</t> | ||
|
||
</templates> |
8 changes: 7 additions & 1 deletion
8
website_recaptcha_v2_form/views/auth_signup_login_templates.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<odoo> | ||
<template id="s_website_form_options" inherit_id="website.snippet_options"> | ||
<xpath expr="//div[@data-js='WebsiteFormEditor']" position="inside"> | ||
<t | ||
t-set="recaptcha_v2_public_key" | ||
t-value="request.env['ir.config_parameter'].sudo().get_param('recaptcha_v2_secret_key')" | ||
/> | ||
<we-checkbox | ||
string="Show reCaptcha v2" | ||
data-toggle-recaptcha-v2="" | ||
data-no-preview="true" | ||
/> | ||
</xpath> | ||
</template> | ||
|
||
</odoo> |