Captive Portal Template

Started by troppodel, February 26, 2016, 12:42:49 PM

Previous topic - Next topic
Hi there
I need to use captive portal with vouchers auth
sorry for my question but My template test no work with vouchers mode
I tried to search by internet but not found info.

here tries to modify the default template index file:

changed dat user is #inputVoucher with new function

    $("#signinvoucher").click(function (event) {
                    event.preventDefault();
                    // hide alerts
                    $("#alertMSG").addClass("hidden");
                    // try to login
                    $.ajax({
                        type: "POST",
                        url: "/api/captiveportal/access/logon/" + zoneid + "/",
                        dataType:"json",
                        data:{ user: $("#inputVoucher").val() }
                    }).done(function(data) {
                        // redirect on successful login
                        if (data['clientState'] == 'AUTHORIZED') {
                            if (getURLparams()['redirurl'] != undefined) {
                                window.location = 'http://'+getURLparams()['redirurl']+'?refresh';
                            } else {
                                // no target, reload page
                                window.location.reload();
                            }
                        } else {
                            $("#inputVoucher").val("");
                            $("#errorMSGtext").html("authentication failed");
                            $("#alertMSG").removeClass("hidden");
                        }
                    }).fail(function(){
                        $("#errorMSGtext").html("unable to connect to authentication server");
                        $("#alertMSG").removeClass("hidden");
                    });
                });

MODIFIED THE FORM:

          <div id="login_password" class="hidden">
              <form class="form-signin">
                  <h2 class="form-signin-heading">Please sign in</h2>
                  <label for="inputVoucher" class="sr-only">Voucher</label>
                  <input type="text" id="inputVoucher" class="form-control" placeholder="Voucher" required autofocus>
                  <button class="btn btn-primary btn-block" id="signinvoucher" type="button">Sign in</button>
              </form>
          </div>

ABOVE ERROR AUTHENTICATION

TRIED OTHER TEMPLATE WITH form method="post":

  <form method="post" action="$PORTAL_ACTION$" class="login" >
    <img src="captiveportal-wlan.png" text-align="center"></br></br>
   <h1>User Authentication</h1>
    <p class="login-p">Enter your valid Username and Password OR Vouchers</p>
   <p class="login-p">Inserisci un utente e una password valida</br>OPPURE </br>IL CODICE VOUCHER</p>
    <input type="text" name="auth_user" class="login-input" placeholder="Username (Utente)" autofocus>
    <input type="password" name="auth_pass" class="login-input" placeholder="Password (Password)">
    <p class="login-p"><font color="#ff6600"><big><big><b>OR</b></big></big></font></p></br>
    <input type="text" name="auth_voucher" class="login-inputv" placeholder="Voucher Code (Codice Voucher)" autofocus>
   <input name="redirurl" value="$PORTAL_REDIRURL$" type="hidden">
   </br>

ERROR NOT FOUND PAGE PORTAL_ACTION

Someone have a work templates with voucher mode?
Someone can support me?

Thanks
Regards

February 26, 2016, 01:35:17 PM #1 Last Edit: February 26, 2016, 01:37:02 PM by DokuKäfer
Take a look on the template from user hollsten

https://forum.opnsense.org/index.php?topic=2196.0
(german thread)

Thanks but if you see this template use only username and password
no voucher

Yes thats correct.
Only Voucher code is not supported in the new Captive Portal (version 16).

https://github.com/opnsense/core/issues/688