]> git.wh0rd.org - tt-rss.git/commitdiff
pref-prefs/otpqrcode: do not show image if otp is enabled
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 3 Sep 2012 14:42:17 +0000 (18:42 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 3 Sep 2012 14:42:17 +0000 (18:42 +0400)
classes/pref/prefs.php

index c6b109877eb8c4095ac0672ad25b3708018541b7..3e93ee4d66374bec9f3871852a20ad45040a27f3 100644 (file)
@@ -632,18 +632,20 @@ class Pref_Prefs extends Handler_Protected {
                require_once "lib/otphp/lib/totp.php";
                require_once "lib/phpqrcode/phpqrcode.php";
 
-               $result = db_query($this->link, "SELECT login,salt
+               $result = db_query($this->link, "SELECT login,salt,otp_enabled
                        FROM ttrss_users
                        WHERE id = ".$_SESSION["uid"]);
 
                $base32 = new Base32();
 
                $login = db_fetch_result($result, 0, "login");
-               $secret = $base32->encode(sha1(db_fetch_result($result, 0, "salt")));
-
-               $topt = new \OTPHP\TOTP($secret);
+               $otp_enabled = sql_bool_to_bool(db_fetch_result($result, 0, "otp_enabled"));
 
-               print QRcode::png($topt->provisioning_uri($login));
+               if (!$otp_enabled) {
+                       $secret = $base32->encode(sha1(db_fetch_result($result, 0, "salt")));
+                       $topt = new \OTPHP\TOTP($secret);
+                       print QRcode::png($topt->provisioning_uri($login));
+               }
        }
 
        function changeotp() {