pdupavillon / express-recaptcha

Implementation of google recaptcha v2 & V3 solutions for express.js
MIT License
128 stars 21 forks source link

Implemented the Example with EJS #31

Closed ripu502 closed 2 years ago

ripu502 commented 5 years ago

Hey, I want to implement the example files with the Ejs. As we all know that the lots of the nodeJs users use Ejs as their templating engine.

Kindly allow me to do that so that the Ejs users can refer it for their implementation in projects.

<html>

<head>
    <title> Express-Recaptcha example</title>
</head>

<body>
    <h1>
        Express-Recaptcha example
    </h1>
    <% if(captcha) {%>
        <form action="<%=path%>" method="POST">
           <%- captcha%>
           <button type='submit'>Verify captcha</button>
           <br>
        </form>
        <% if (path === '/v3') {%>
           <a href="/">Express Recaptcha V2</a>
        <%}else{%>

              <% if (path === '/dark') {%>
                 <a href="/">Light Theme</a>
                 <br>
                 <a href="/v3">Express Recaptcha V3</a>
                  <% }else{%>
                      <a href="/dark"> Dark Theme</a>
                    <br>
                      <a href="/v3">Express Recaptcha V3</a>
                   <%}%>
    <% } } else {%>
         <% if (error){%>
             <div style="color:red">Error : <%=error%></div>
             <% }else{ %>
                  <div style="color:green">Data : <%=data%></div>
               <a href="<%= path%>">Retry</a>
               <% }%>
    <%}%>
        <script>
            function cb(token) {
                console.log('token', token);
                var input = document.createElement('input');
                input.setAttribute('type', 'text');
                input.setAttribute('name', 'g-recaptcha-response');
                input.setAttribute('value', token);
                document.getElementsByTagName('form')[0].appendChild(input);
            }
        </script>
    </body>
</html>

I will be waiting for your respective reply.

gillesheinesch commented 4 years ago

Did you try it out already?

ripu502 commented 4 years ago

Yes

On Fri, 15 Nov, 2019, 11:57 PM Gilles Heinesch, notifications@github.com wrote:

Did you try it out already?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pdupavillon/express-recaptcha/issues/31?email_source=notifications&email_token=AKD6IVPO27NAPPMAZMH7PR3QT3SYDA5CNFSM4HMKMCF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEGJZZY#issuecomment-554474727, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKD6IVK66MOEKQG7XQ5ZKZTQT3SYDANCNFSM4HMKMCFQ .

ripu502 commented 4 years ago

Please add my ejs code in this module example as most of the developers use ejs as a templating engine than a pug. It will be convenient for other developers. It was difficult for me to understand the pub code. I have implemented the code, I may not conflict any code.

pdupavillon commented 2 years ago

ejs example has been added