OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • Profile of troppodel »
  • Show Posts »
  • Topics
  • Profile Info
    • Summary
    • Show Stats
    • Show Posts...
      • Messages
      • Topics
      • Attachments

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

  • Messages
  • Topics
  • Attachments

Topics - troppodel

Pages: [1]
1
16.1 Legacy Series / Captive Portal Template
« on: February 26, 2016, 12:42:49 pm »
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

Pages: [1]
OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2