Voucher only template
-
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 -
@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
-
@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.
-
@papdee
Just Fantastic !!!!
And soooo easy to implement
Thanks a lot for that trick
Regards
Pierre -
@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 -
@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
-
@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 :
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.
-
@gertjan
Thanks again I will try that , as you said .... Next update alle need to be redone again -
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??
-
@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 ;))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.
-
@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.
-
@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 ^^