]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
ddns.cgi: Fix sanity check logic.
authorStefan Schantl <stefan.schantl@ipfire.org>
Tue, 6 Jul 2021 16:08:29 +0000 (18:08 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 7 Jul 2021 09:34:31 +0000 (09:34 +0000)
The input validation did not work in the proper way. It allways
reported "No password" when using a provider which supports token and
the token has been given.

This of course is wrong and leaded to unuseable providers.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
html/cgi-bin/ddns.cgi

index e30aa3d4fa51ebca1c5b903bc19a2900279f8b24..0e3ccbe4532301bb310ad38415c0d1f8b6f01a82 100644 (file)
@@ -171,20 +171,28 @@ if (($settings{'ACTION'} eq $Lang::tr{'add'}) || ($settings{'ACTION'} eq $Lang::
                $errormessage = $Lang::tr{'invalid domain name'};
        }
 
-       # Check if a username has been sent.
-       if ($settings{'LOGIN'} eq '') {
-               $errormessage = $Lang::tr{'username not set'};
-       }
+       # Check if the choosen provider supports token based authentication.
+       if ($settings{'SERVICE'} ~~ @token_provider) {
+               # Check if a token has been given.
+               unless ($settings{'TOKEN'}) {
+                       $errormessage = $Lang::tr{'token not set'};
+               }
 
-       # Check if a password has been typed in.
-       # freedns.afraid.org does not require this field.
-       if (($settings{'PASSWORD'} eq '') && ($settings{'SERVICE'} ne 'freedns.afraid.org') && ($settings{'SERVICE'} ne 'regfish.com')) {
-               $errormessage = $Lang::tr{'password not set'};
-       }
+               # Automatically set the username to token.
+               $settings{'LOGIN'} = "token";
 
-       # Check if a token has been given for provider which support tokens.
-       if (($settings{'SERVICE'} ~~ @token_provider) && ($settings{'TOKEN'} eq '')) {
-               $errormessage = $Lang::tr{'token not set'};
+       # A provider without token support has been choosen.
+       } else {
+               # Check if a username has been sent.
+               if ($settings{'LOGIN'} eq '') {
+                       $errormessage = $Lang::tr{'username not set'};
+               }
+
+               # Check if a password has been typed in.
+               # freedns.afraid.org does not require this field.
+               if (($settings{'PASSWORD'} eq '') && ($settings{'SERVICE'} ne 'freedns.afraid.org') && ($settings{'SERVICE'} ne 'regfish.com')) {
+                       $errormessage = $Lang::tr{'password not set'};
+               }
        }
 
        # Go furter if there was no error.