Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Voucher only template

    Captive Portal
    4
    12
    1.6k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ?
      A Former User
      last edited by

      Hello Everybody

      As I would like to have only the Voucher field displayed on the client side omitting the user/password I was wondering if someone has already developped a html template for that purpose to have the connection page just asking for a voucher?

      Thanks
      Pierre

      GertjanG P 2 Replies Last reply Reply Quote 0
      • GertjanG
        Gertjan @A Former User
        last edited by

        @pierrelyon

        Check out the default login page.
        You already discovered, when you activate vouchers, a third 'text box' is present on the login page.
        And true, you might design your own 'html' login page that only shows/asks the voucher code.

        See also here : /etc/inc/captiveportal.inc : line 145

        No "help me" PM's please. Use the forum, the community will thank you.
        Edit : and where are the logs ??

        1 Reply Last reply Reply Quote 0
        • P
          papdee @A Former User
          last edited by

          @pierrelyon the simplest method would be to edit the HTML in the captive portal and simply add the HTML code

          input type="hidden"

          inside the sideways carets <> for theusername and password fields.

          ? 2 Replies Last reply Reply Quote 0
          • ?
            A Former User @papdee
            last edited by

            @papdee
            Just Fantastic !!!!
            And soooo easy to implement
            Thanks a lot for that trick
            Regards
            Pierre

            1 Reply Last reply Reply Quote 0
            • ?
              A Former User @papdee
              last edited by

              @papdee
              The idea was excellent but ....
              It last until the next reboot 😢
              Today I perform an update to 2.5.1 so defecto the sytem reboot and the User/password fileds were back on the logging page.
              The seek is not ended
              I really would like to have that persistant.
              Any idea welcome

              ? 1 Reply Last reply Reply Quote 0
              • ?
                A Former User @A Former User
                last edited by

                @pierrelyon
                Got it !!!!
                As far as I understand each time pfsense reboot it rebuild the html file that will be displayed on the cpative portal.
                So the place to make the change is in the tempalte that is used to build that HTML and as suggested by @Gertjan I checked the captiveportal.inc file located in /etc/inc
                and the it is , two lines that show up the HTML code

                <input type="text" name="auth_user" placeholder="{$translated_text1}" id="auth_user">
                <input type="password" name="auth_pass" placeholder="{$translated_text2}" id="auth_pass">

                So I replace the "text" and "password" by "hidden" and the two lines show now as :

                <input type="hidden" name="auth_user" placeholder="{$translated_text1}" id="auth_user">
                <input type="hidden" name="auth_pass" placeholder="{$translated_text2}" id="auth_pass">

                That couple of lines show two tine in the captiveportal.inc file
                so I chnge them all.

                Save the file
                Reboot the system
                and bingo !!!
                That time only the voucher field was showing up as expected !!!

                Thanks again to Gertjan and Papdee for there helpfull suggestions

                GertjanG 1 Reply Last reply Reply Quote 0
                • GertjanG
                  Gertjan @A Former User
                  last edited by Gertjan

                  @pierrelyon said in Voucher only template:

                  That couple of lines show two tine in the captiveportal.inc file
                  so I chnge them all.

                  Actually, there is no need to edit these files.
                  You can use the /etc/inc/captiveportal.inc file as what it actually is : a manual ;) (ok, it's also a script /the actual code).
                  All you need is a web browser.

                  Visit the default captive portal web page.
                  Switch to developer mode, and have the "html source code" shown.
                  Use this "code" to make your own captive portal login page.
                  You could even mix in PHP, Javascript, etc etc etc etc etc.
                  Save this file, import it in the captive portal settings page.

                  Btw : make also a 'html' page that shows an 'error', this page is shown when the captive portal's login page fails to login, for example, after a wrong password.

                  By now you understand why they show this :

                  319e9d32-ea0b-4eb1-801e-60db047373d6-image.png

                  on the captive portal's settings page.

                  Again : no need to edit pfSense source files, as they get overwritten during the next update.

                  edit : also : no need to reboot. This method is operational right away.

                  No "help me" PM's please. Use the forum, the community will thank you.
                  Edit : and where are the logs ??

                  ? 1 Reply Last reply Reply Quote 0
                  • ?
                    A Former User @Gertjan
                    last edited by

                    @gertjan
                    Thanks again I will try that , as you said .... Next update alle need to be redone again 👍

                    1 Reply Last reply Reply Quote 0
                    • R
                      rotanon
                      last edited by

                      Im confused.

                      So the advice here is to simply "hide" the username and password field in the html. Dont these input fields get used by Captive Portal to authenticate the user along with the voucher presented??

                      GertjanG P 2 Replies Last reply Reply Quote 0
                      • GertjanG
                        Gertjan @rotanon
                        last edited by Gertjan

                        @rotanon said in Voucher only template:

                        So the advice here is to simply "hide" the username and password field in the html.

                        Hiding it will do just fine.
                        You could probably complexly omit them also.
                        It's open source, so see the source why ;))

                        Here, line 196.

                        It says : If for that portal instance (zone) the voucher mode is active
                        and the user pressed the Accept button,
                        and a voucher code was entered
                        Or a voucher is set in the URL ( see https://redmine.pfsense.org/issues/1984 )
                        Then to the 'voucher login stuff'

                        User and password chechking is done later on in this file - done later in the execution path.

                        No "help me" PM's please. Use the forum, the community will thank you.
                        Edit : and where are the logs ??

                        1 Reply Last reply Reply Quote 0
                        • P
                          papdee @rotanon
                          last edited by

                          @rotanon The voucher field in its default state is visible whether or not you have configured the captive portal to use vouchers or not. Maybe you do not mind this but personally I think it makes the captive portal too confusing to the end user. If you have configured your captive portal to allow just "accept" the terms then you can edit the html file and simply find the field tag and type in "hidden" to hide the voucher field from view.

                          GertjanG 1 Reply Last reply Reply Quote 0
                          • GertjanG
                            Gertjan @papdee
                            last edited by

                            @papdee said in Voucher only template:

                            @rotanon The voucher field in its default state is visible whether or not you have configured the captive portal to use vouchers or not. Maybe you do not mind this but personally I think it makes the captive portal too confusing to the end user. If you have configured your captive portal to allow just "accept" the terms then you can edit the html file and simply find the field tag and type in "hidden" to hide the voucher field from view.

                            Or : use the power of PHP :

                            This is the default html structure :

                            <form method="post" action="$PORTAL_ACTION$">
                               <input name="auth_user" type="text">
                               <input name="auth_pass" type="password">
                               <input name="auth_voucher" type="text">
                               <input name="redirurl" type="hidden" value="$PORTAL_REDIRURL$">
                               <input name="zone" type="hidden" value="$PORTAL_ZONE$">
                               <input name="accept" type="submit" value="Continue">
                            </form>
                            

                            Make it look like :

                            <form method="post" action="$PORTAL_ACTION$">
                               <input name="auth_user" type="text">
                               <input name="auth_pass" type="password">
                            <?php
                            	global $config, $cpzone;
                            	if(isset($config['voucher'][$cpzone]['enable'])) {
                            ?>
                               <input name="auth_voucher" type="text">
                            <?php
                            	}
                            ?>
                               <input name="redirurl" type="hidden" value="$PORTAL_REDIRURL$">
                               <input name="zone" type="hidden" value="$PORTAL_ZONE$">
                               <input name="accept" type="submit" value="Continue">
                            </form>
                            

                            Now the voucher entry filed iwill not get showed when the vouchers are not avtivated for the instance "cpzone".
                            You could even hide user/password entries if vouchers are activated.

                            The limit is your imagination ^^

                            No "help me" PM's please. Use the forum, the community will thank you.
                            Edit : and where are the logs ??

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post
                            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.