3 commits - lib/kolab_api_controller.php lib/kolab_client_task.php

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Fri Aug 10 19:40:54 CEST 2012


 lib/kolab_api_controller.php |   37 +++++++++++++++++++++++++++++++++----
 lib/kolab_client_task.php    |   24 ------------------------
 2 files changed, 33 insertions(+), 28 deletions(-)

New commits:
commit 1ee8c3aeb69a5c1328b7f41f154c85bd5d0c1ba8
Merge: 479f470 31d013e
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Fri Aug 10 19:40:41 2012 +0200

    Merge branch 'master' of ssh://git.kolab.org/git/kolab-wap



commit 479f4702d7e5c40b3bae46dd6816f8a0c1fb0e8a
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Fri Aug 10 19:39:29 2012 +0200

    Allow logging in without specifying a domain name space (#871)
    
      Inherently, also remove the domain name space selector from the login form.
    
      Users that wish to log in to a specific domain name space not the primary
      domain for the deployment can login in with 'username at domain'.

diff --git a/lib/kolab_api_controller.php b/lib/kolab_api_controller.php
index 575ba26..f5e67d7 100644
--- a/lib/kolab_api_controller.php
+++ b/lib/kolab_api_controller.php
@@ -282,7 +282,29 @@ class kolab_api_controller
         session_start();
 
         $_SESSION['user'] = new User();
-        $valid = $_SESSION['user']->authenticate($postdata['username'], $postdata['password'], $postdata['domain']);
+
+        if (empty($postdata['domain'])) {
+            Log::debug("No login domain specified. Attempting to derive from username.");
+            if (count(explode('@', $postdata['username'])) > 1) {
+                $login = explode('@', $postdata['username']);
+                $username = array_shift($login);
+                $domain = array_shift($login);
+            }
+            else {
+                Log::debug("No domain name space in the username, using the primary domain");
+                $conf = Conf::get_instance();
+                $domain = $conf->get('kolab', 'primary_domain');
+            }
+        }
+        else {
+            $domain = $postdata['domain'];
+        }
+
+        if (empty($username)) {
+            $username = $postdata['username'];
+        }
+
+        $valid = $_SESSION['user']->authenticate($username, $postdata['password'], $domain);
 
         // start new (PHP) session
         if ($valid) {
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index b41d75b..1352ef4 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -635,22 +635,8 @@ class kolab_client_task
 
         $auth = Auth::get_instance();
         $conf = Conf::get_instance();
-        $dna = $conf->get('domain_name_attribute');
         $auth->connect();
 
-        $domains = Array();
-        $_domains = $auth->list_domains();
-
-        foreach ($_domains as $domain_dn => $domain_attrs) {
-            if (is_array($domain_attrs[$dna])) {
-                $domain = array_shift($domain_attrs[$dna]);
-            } else {
-                $domain = $domain_attrs[$dna];
-            }
-
-            $domains[$domain] = $domain;
-        }
-
         $username = kolab_html::label(array(
                 'for'     => 'login_name',
                 'content' => $this->translate('login.username')), true)
@@ -670,15 +656,6 @@ class kolab_client_task
                 'name'  => 'login[password]',
                 'value' => ''));
 
-        $domain = kolab_html::label(array(
-                'for'   => 'login_domain',
-                'content' => $this->translate('login.domain')), true)
-            . kolab_html::select(array(
-                'type'  => 'select',
-                'id'    => 'login_domain',
-                'name'  => 'login[domain]',
-                'options' => $domains));
-
         $button = kolab_html::input(array(
             'type'  => 'submit',
             'id'    => 'login_submit',
@@ -691,7 +668,6 @@ class kolab_client_task
             'action' => '?'),
             kolab_html::span(array('content' => $username))
             . kolab_html::span(array('content' => $password))
-            . kolab_html::span(array('content' => $domain))
             . $button);
 
         return $form;


commit 2558a1d859603bdc2ffd85a2cc669cd96001f1f9
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Fri Aug 10 18:18:59 2012 +0200

    Make the api more generic by using the configured domain name attribute

diff --git a/lib/kolab_api_controller.php b/lib/kolab_api_controller.php
index e0dbf8b..575ba26 100644
--- a/lib/kolab_api_controller.php
+++ b/lib/kolab_api_controller.php
@@ -308,6 +308,13 @@ class kolab_api_controller
 
         $auth = Auth::get_instance();
 
+        // Get the domain name attribute
+        $conf = Conf::get_instance();
+        $dna = $conf->get('ldap', 'domain_name_attribute');
+        if (empty($dna)) {
+            $dna = 'associateddomain';
+        }
+
         $this->domains = $auth->list_domains();
 
         $result = array();
@@ -323,9 +330,9 @@ class kolab_api_controller
 
         // add capabilities of all registered services
         foreach ($this->domains as $domain) {
-            // TODO: 'associateddomain' is very specific to 389ds based deployments, and this
-            // is supposed to be very generic.
-            $domain_name = is_array($domain) ? (is_array($domain['associateddomain']) ? $domain['associateddomain'][0] : $domain['associateddomain']) : $domain;
+
+            $domain_name = is_array($domain) ? (is_array($domain[$dna]) ? $domain[$dna][0] : $domain[$dna]) : $domain;
+
             // define our very own capabilities
             $actions = array(
                 'system.quit'      => array('type' => 'w'),





More information about the commits mailing list