summaryrefslogtreecommitdiff
path: root/classes/auth
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2012-09-03 18:53:19 +0400
committerAndrew Dolgov <[email protected]>2012-09-03 18:53:19 +0400
commit4e70344bbf4d7e2d0a9e5a87c6c10973b519cafa (patch)
treeca32cb17516946d918b5ffb9c346a3a8c38a5b13 /classes/auth
parent973392b9f55fa9a70cdcde42adeed10467dd5ba1 (diff)
auth internal: fix login screen warning
Diffstat (limited to 'classes/auth')
-rw-r--r--classes/auth/internal.php66
1 files changed, 34 insertions, 32 deletions
diff --git a/classes/auth/internal.php b/classes/auth/internal.php
index a4e8b471c..da2d3668f 100644
--- a/classes/auth/internal.php
+++ b/classes/auth/internal.php
@@ -12,39 +12,41 @@ class Auth_Internal extends Auth_Base {
$result = db_query($this->link, "SELECT otp_enabled,salt FROM ttrss_users WHERE
login = '$login'");
- require_once "lib/otphp/vendor/base32.php";
- require_once "lib/otphp/lib/otp.php";
- require_once "lib/otphp/lib/totp.php";
-
- $base32 = new Base32();
-
- $otp_enabled = sql_bool_to_bool(db_fetch_result($result, 0, "otp_enabled"));
- $secret = $base32->encode(sha1(db_fetch_result($result, 0, "salt")));
-
- $topt = new \OTPHP\TOTP($secret);
- $otp_check = $topt->now();
-
- if ($otp_enabled) {
- if ($otp) {
- if ($otp != $otp_check) {
- return false;
+ if (db_num_rows($result) > 0) {
+ require_once "lib/otphp/vendor/base32.php";
+ require_once "lib/otphp/lib/otp.php";
+ require_once "lib/otphp/lib/totp.php";
+
+ $base32 = new Base32();
+
+ $otp_enabled = sql_bool_to_bool(db_fetch_result($result, 0, "otp_enabled"));
+ $secret = $base32->encode(sha1(db_fetch_result($result, 0, "salt")));
+
+ $topt = new \OTPHP\TOTP($secret);
+ $otp_check = $topt->now();
+
+ if ($otp_enabled) {
+ if ($otp) {
+ if ($otp != $otp_check) {
+ return false;
+ }
+ } else {
+ ?><html>
+ <head><title>Tiny Tiny RSS</title></head>
+ <body>
+ <form method="POST">
+ <input type="hidden" name="login_action" value="do_login">
+ <input type="hidden" name="login" value="<?php echo htmlspecialchars($login) ?>">
+ <input type="hidden" name="password" value="<?php echo htmlspecialchars($password) ?>">
+
+ <label><?php echo __("Please enter your one time password:") ?></label>
+ <input type="password" size="6" name="otp"/>
+ <input type="submit" value="Continue"/>
+ </form>
+ </form>
+ <?php
+ exit;
}
- } else {
- ?><html>
- <head><title>Tiny Tiny RSS</title></head>
- <body>
- <form method="POST">
- <input type="hidden" name="login_action" value="do_login">
- <input type="hidden" name="login" value="<?php echo htmlspecialchars($login) ?>">
- <input type="hidden" name="password" value="<?php echo htmlspecialchars($password) ?>">
-
- <label><?php echo __("Please enter your one time password:") ?></label>
- <input type="password" size="6" name="otp"/>
- <input type="submit" value="Continue"/>
- </form>
- </form>
- <?php
- exit;
}
}
}