summaryrefslogtreecommitdiffstats
path: root/lib/kolab_api_controller.php
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-08-10 19:39:29 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-08-10 19:39:29 +0200
commit479f4702d7e5c40b3bae46dd6816f8a0c1fb0e8a (patch)
treedf7b9b1300b12716980cc76176a3277987b11e58 /lib/kolab_api_controller.php
parent2558a1d859603bdc2ffd85a2cc669cd96001f1f9 (diff)
downloadwebadmin-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'.
Diffstat (limited to 'lib/kolab_api_controller.php')
-rw-r--r--lib/kolab_api_controller.php24
1 files changed, 23 insertions, 1 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) {