]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Adding support for http_auth 284/head 285/head
authorDenis Sacchet <denis@sacchet.fr>
Sun, 20 Oct 2013 21:28:45 +0000 (23:28 +0200)
committerDenis Sacchet <denis@sacchet.fr>
Sun, 20 Oct 2013 21:28:45 +0000 (23:28 +0200)
inc/poche/Database.class.php
index.php
themes/default/login.twig

index 5c40b026a18a949aeacd5ef2077c9cf9fb9f262f..1d3ff0c29752f11a1e3a62a9fa77b9930a209179 100644 (file)
@@ -87,6 +87,17 @@ class Database {
         return $user_config;
     }
 
+    public function userExists($username) {
+        $sql = "SELECT * FROM users WHERE username=?";
+        $query = $this->executeQuery($sql, array($username));
+        $login = $query->fetchAll();
+        if (isset($login[0])) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
     public function login($username, $password) {
         $sql = "SELECT * FROM users WHERE username=? AND password=?";
         $query = $this->executeQuery($sql, array($username, $password));
index d79f3f958a86d5e260254aae32af39357836a4bd..d400354d2fd2a92bae540ae38e6c2e7511814d85 100644 (file)
--- a/index.php
+++ b/index.php
@@ -82,9 +82,17 @@ if (Session::isLogged()) {
     $tpl_file = Tools::getTplFile($view);
     $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id));
 } elseif(isset($_SERVER['PHP_AUTH_USER'])) {
-    $poche->login($referer);
+    if($poche->store->userExists($_SERVER['PHP_AUTH_USER'])) {
+        $poche->login($referer);
+    } else {
+        $poche->messages->add('e', _('login failed: user doesn\'t exist'));
+        Tools::logm('user doesn\'t exist');
+        $tpl_file = Tools::getTplFile('login');
+        $tpl_vars['http_auth'] = 1;
+    }
 } else {
     $tpl_file = Tools::getTplFile('login');
+    $tpl_vars['http_auth'] = 0;
 }
 
 # because messages can be added in $poche->action(), we have to add this entry now (we can add it before)
index 0ae130bc0240b49f305b1946fae412d941c30431..2e48052ba35187acb0dec07a0789f54ff629a52c 100644 (file)
@@ -2,6 +2,7 @@
 
 {% block title %}{% trans "login to your poche" %}{% endblock %}
 {% block content %}
+    {% if http_auth == 0 %}
             <form method="post" action="?login" name="loginform">
                 <fieldset class="w500p center">
                     <h2 class="mbs txtcenter">{% trans "login to your poche" %}</h2>
@@ -29,4 +30,5 @@
                 <input type="hidden" name="returnurl" value="{{ referer }}">
                 <input type="hidden" name="token" value="{{ token }}">
             </form>
-{% endblock %}
\ No newline at end of file
+    {% endif %}
+{% endblock %}