summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-08-10 17:39:29 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-08-10 17:39:29 (GMT)
commit479f4702d7e5c40b3bae46dd6816f8a0c1fb0e8a (patch)
treedf7b9b1300b12716980cc76176a3277987b11e58
parent2558a1d859603bdc2ffd85a2cc669cd96001f1f9 (diff)
downloadkolab-wap-479f4702d7e5c40b3bae46dd6816f8a0c1fb0e8a.tar.gz
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@domain'.
-rw-r--r--lib/kolab_api_controller.php24
-rw-r--r--lib/kolab_client_task.php24
2 files changed, 23 insertions, 25 deletions
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;