This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit c2e4aa930530216e977d46389325f93cd3f74ed5 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Tue Jun 27 11:09:43 2017 +0200 empécher la validation des formulaire par les robots (ref #76) --- pollen-ui-riot-js/src/main/web/tag/SignIn.tag.html | 4 ++- pollen-ui-riot-js/src/main/web/tag/SignUp.tag.html | 5 +-- .../src/main/web/tag/UserCard.tag.html | 4 ++- .../src/main/web/tag/UserProfile.tag.html | 7 +++-- .../main/web/tag/components/HumanInput.tag.html | 36 ++++++++++++++++++++++ .../src/main/web/tag/poll/Comments.tag.html | 12 +++++--- .../src/main/web/tag/poll/EditPoll.tag.html | 7 +++-- .../src/main/web/tag/poll/Polls.tag.html | 6 ++-- .../src/main/web/tag/poll/Votes.tag.html | 11 ++++--- .../src/main/web/tag/popup/Modal.tag.html | 4 ++- 10 files changed, 76 insertions(+), 20 deletions(-) diff --git a/pollen-ui-riot-js/src/main/web/tag/SignIn.tag.html b/pollen-ui-riot-js/src/main/web/tag/SignIn.tag.html index 6c5e6d31..0a0d8405 100644 --- a/pollen-ui-riot-js/src/main/web/tag/SignIn.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/SignIn.tag.html @@ -20,11 +20,13 @@ */ require("./popup/NewPassword.tag.html"); require("./SignUp.tag.html"); +require("./components/HumanInput.tag.html"); <SignIn> <div class="body-container colors-main sign-in-layer" show={openSignIn}> <div class="body-content"> <h1 class="c-heading">{__.title}</h1> - <form class="signin" onsubmit={signIn}> + <form class="signin"> + <HumanInput onsubmit={signIn}/> <div class="o-form-element"> <div class="c-input-group c-input-group--stacked"> <div class="o-field"> diff --git a/pollen-ui-riot-js/src/main/web/tag/SignUp.tag.html b/pollen-ui-riot-js/src/main/web/tag/SignUp.tag.html index 622875c4..5fb2c701 100644 --- a/pollen-ui-riot-js/src/main/web/tag/SignUp.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/SignUp.tag.html @@ -20,12 +20,13 @@ */ let route = require("riot-route"); require("./popup/ResendValidation.tag.html"); +require("./components/HumanInput.tag.html"); <SignUp class="body-content"> <div class="container"> <h1 class="c-heading"><i class="fa fa-user-plus"/> {__.title}</h1> - <form ref="user" class="signup" onsubmit="{signUp}"> - + <form ref="user" class="signup"> + <HumanInput onsubmit="{signUp}"/> <div class="o-form-element"> <label class="c-label" for="name">{__.name}</label> <input class="c-field {c-field--error : errors.name}" diff --git a/pollen-ui-riot-js/src/main/web/tag/UserCard.tag.html b/pollen-ui-riot-js/src/main/web/tag/UserCard.tag.html index 8cefac50..0cf64484 100644 --- a/pollen-ui-riot-js/src/main/web/tag/UserCard.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/UserCard.tag.html @@ -1,3 +1,4 @@ +require("./components/HumanInput.tag.html"); <UserCard class="card"> <div class="user-card-view" if={!editing}> <div class="login"> @@ -28,7 +29,8 @@ </div> - <form class="user-card-edit" if={editing} onsubmit={saveUser}> + <form class="user-card-edit" if={editing}> + <HumanInput onsubmit={saveUser}/> <div class="o-form-element"> <label class="c-label" for="name">{__.name}</label> <input type="text" diff --git a/pollen-ui-riot-js/src/main/web/tag/UserProfile.tag.html b/pollen-ui-riot-js/src/main/web/tag/UserProfile.tag.html index 0b5951b9..bbc65b4f 100644 --- a/pollen-ui-riot-js/src/main/web/tag/UserProfile.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/UserProfile.tag.html @@ -1,9 +1,11 @@ +require("./components/HumanInput.tag.html"); <UserProfile> <div class="container"> <h1 class="c-heading"><i class="fa fa-user"/> {__.title}</h1> <hr> - <form ref="identity-form" class="identity-form" onsubmit="{submitIdentity}"> + <form ref="identity-form" class="identity-form"> + <HumanInput onsubmit={submitIdentity}/> <h3 class="c-heading"><i class="fa fa-address-card"/> {__.identity}</h3> <div class="o-form-element"> <label class="c-label" for="name">{__.name}</label> @@ -55,7 +57,8 @@ </div> </form> <hr> - <form ref="password-form" class="password-form" onsubmit="{submitPassword}"> + <form ref="password-form" class="password-form"> + <HumanInput onsubmit={submitPassword}/> <h3 class="c-heading"><i class="fa fa-key"/> {__.passwordChange}</h3> <div class="o-form-element"> <label class="c-label" for="oldPassword">{__.oldPassword}</label> diff --git a/pollen-ui-riot-js/src/main/web/tag/components/HumanInput.tag.html b/pollen-ui-riot-js/src/main/web/tag/components/HumanInput.tag.html new file mode 100644 index 00000000..4e479a12 --- /dev/null +++ b/pollen-ui-riot-js/src/main/web/tag/components/HumanInput.tag.html @@ -0,0 +1,36 @@ +<HumanInput> + <input type="text" + id="pollenInput" + name="pollenInput" + ref="pollenInput"/> + + <script type="es6"> + + this.check = e => { + if (this.refs.pollenInput.value.length === 0) { + return this.opts.onsubmit(e); + } + e.preventDefault(); + e.stopPropagation(); + this.logger.warn("You are a Robot !!!"); + return false; + }; + + + let form = this.root.parentNode; + if (form.tagName !== "FORM") { + this.logger.error("<HumanInput> parent must be a <form>"); + } else { + form.onsubmit = this.check; + } + + </script> + + <style> + #pollenInput { + display: none; + } + + </style> + +</HumanInput> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Comments.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Comments.tag.html index 553416de..3f4d9e5e 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Comments.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Comments.tag.html @@ -1,5 +1,6 @@ require("../Pagination.tag.html"); require("../components/LetterAvatar.tag.html"); +require("../components/HumanInput.tag.html"); require("./Report.tag.html"); <Comments> @@ -22,7 +23,8 @@ require("./Report.tag.html"); <i class="fa fa-times"/> </button> </div> - <form onsubmit="{addComment}" class="comment-form"> + <form class="comment-form"> + <HumanInput onsubmit="{addComment}"/> <div class="o-form-element"> <div class="o-field o-field--icon-left"> <i class="fa fa-fw fa-user c-icon"></i> @@ -111,8 +113,8 @@ require("./Report.tag.html"); </div> </div> <form if={commentEditing === comment} - onsubmit="{updateComment}" class="comment-form"> + <HumanInput onsubmit="{updateComment}"/> <div class="comment"> <div class="comment-user"> <div class="o-form-element"> @@ -124,7 +126,7 @@ require("./Report.tag.html"); ref="editAuthor" required value={commentEditing.authorName} - placeholder="{__.authorPlaceholder}"> + placeholder="{parent.__.authorPlaceholder}"> </div> </div> @@ -137,7 +139,7 @@ require("./Report.tag.html"); name="editText" required value={commentEditing.text} - placeholder="{__.textPlaceholder}"/> + placeholder="{parent.__.textPlaceholder}"/> </div> </div> </div> @@ -235,7 +237,7 @@ require("./Report.tag.html"); this.commentEditing = comment; }; - this.updateComment = (e) => { + this.updateComment = e => { e.preventDefault(); e.stopPropagation(); this.commentEditing.authorName = this.refs.editAuthor.value; diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/EditPoll.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/EditPoll.tag.html index 472dd76d..e9dc00e7 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/EditPoll.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/EditPoll.tag.html @@ -23,9 +23,11 @@ require("./Choices.tag.html"); require("./Settings.tag.html"); require("./Voters.tag.html"); require("./Summary.tag.html"); +require("../components/HumanInput.tag.html"); <EditPoll> - <form show={loaded} ref="poll" onsubmit="{submitStep}" class="form"> + <form show={loaded} ref="poll" class="form"> + <HumanInput onsubmit="{submitStep}"/> <div class="tabs tabs-one-small"> <div each={step, index in form.steps} class="tab {selected : !showSummary && form.step === index}"> <button type="submit" if="{form.step > index || !form.creation}" class="{cursor-pointer: !form.creation}" onclick="{goto(index)}"> @@ -98,7 +100,7 @@ require("./Summary.tag.html"); this.loaded = true; this.update(); if (this.showSummary) { - this.bus.trigger("pageChanged", this.form.model.title); + this.bus.trigger("pageChanged", this.form.model.title); } }; if (this.opts.pollId) { @@ -129,6 +131,7 @@ require("./Summary.tag.html"); } if (this.callAfterSubmit) { this.callAfterSubmit(); + this.update(); } }; diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag.html index 96b5e3b9..9a4c60db 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Polls.tag.html @@ -1,5 +1,6 @@ require("../Pagination.tag.html"); require("./PollCard.tag.html"); +require("../components/HumanInput.tag.html"); <Polls> <div class="container" > <div show="{loaded}"> @@ -35,7 +36,8 @@ require("./PollCard.tag.html"); <div if={opts.method === "createdPolls"}> <hr/> - <form onsubmit="{assignPoll}" class="assign-form"> + <form class="assign-form"> + <HumanInput onsubmit="{assignPoll}"/> <h3 class="c-heading">{__.assignPollToMe_title}</h3> <div class="o-form-element"> @@ -144,6 +146,6 @@ require("./PollCard.tag.html"); .o-form-element.sort .c-input-group { width: 200px; } - + </style> </Polls> diff --git a/pollen-ui-riot-js/src/main/web/tag/poll/Votes.tag.html b/pollen-ui-riot-js/src/main/web/tag/poll/Votes.tag.html index 0c6083b8..bbc9ba16 100644 --- a/pollen-ui-riot-js/src/main/web/tag/poll/Votes.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/poll/Votes.tag.html @@ -1,6 +1,7 @@ require("./Choice.tag.html"); require("./ChoiceView.tag.html"); require("./Podium.tag.html"); +require("../components/HumanInput.tag.html"); <Votes> <div class="container"> <div show="{loaded}"> @@ -9,7 +10,8 @@ require("./Podium.tag.html"); <div class="voters"> - <form ref="formAddVote" onsubmit="{addVote}" class="fix"> + <form ref="formAddVote" class="fix"> + <HumanInput onsubmit="{addVote}"/> <div class="current-voter"> <div class="o-field o-field--icon-left o-field--icon-right" if={poll.canVote} > @@ -99,7 +101,8 @@ require("./Podium.tag.html"); onclick="{onHideVotes}"> <i class="fa fa-caret-left"/> </button> - <form if={showVotes} each={vote, index in poll.votes} class="vote {separator-right : index < (poll.votes.length -1)}" onsubmit="{updateVote(vote)}"> + <form if={showVotes} each={vote, index in poll.votes} class="vote {separator-right : index < (poll.votes.length -1)}"> + <HumanInput onsubmit="{updateVote(vote)}"/> <div class="voter"> <span class="voter-name" if="{vote.id !== voteId}"> @@ -182,8 +185,8 @@ require("./Podium.tag.html"); </div> <form ref="formAddChoice" - if={poll.status === "ADDING_CHOICES"} - onsubmit="{addChoice}"> + if={poll.status === "ADDING_CHOICES"}> + <HumanInput onsubmit="{addChoice}"/> <div class="o-form-element"> <label class="c-label" for="choice">{__.addChoice}</label> <div class="c-input-group"> diff --git a/pollen-ui-riot-js/src/main/web/tag/popup/Modal.tag.html b/pollen-ui-riot-js/src/main/web/tag/popup/Modal.tag.html index 11421365..7dfbc060 100644 --- a/pollen-ui-riot-js/src/main/web/tag/popup/Modal.tag.html +++ b/pollen-ui-riot-js/src/main/web/tag/popup/Modal.tag.html @@ -1,8 +1,10 @@ +require("../components/HumanInput.tag.html"); <modal show={openModal}> <div class="c-overlay"></div> <div class="o-modal u-highest"> - <form class="c-card c-card--higher" onsubmit={submit}> + <form class="c-card c-card--higher"> + <HumanInput onsubmit={submit}/> <header class="c-card__header"> <h2 class="c-heading"> {opts.header} -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.