Merge 0.10->trunk
[prosody.git] / core / usermanager.lua
index d874447d9dc64f59d853e6217c6057976374bdbc..d5132662b08a9b9fb404de2b0682704e88bbefcc 100644 (file)
@@ -81,6 +81,7 @@ local function set_password(username, password, host)
 end
 
 local function user_exists(username, host)
+       if hosts[host].sessions[username] then return true; end
        return hosts[host].users.user_exists(username);
 end
 
@@ -111,7 +112,6 @@ local function is_admin(jid, host)
        if host and not hosts[host] then return false; end
        if type(jid) ~= "string" then return false; end
 
-       local is_admin;
        jid = jid_bare(jid);
        host = host or "*";
 
@@ -122,8 +122,7 @@ local function is_admin(jid, host)
                if type(host_admins) == "table" then
                        for _,admin in ipairs(host_admins) do
                                if jid_prep(admin) == jid then
-                                       is_admin = true;
-                                       break;
+                                       return true;
                                end
                        end
                elseif host_admins then
@@ -131,12 +130,11 @@ local function is_admin(jid, host)
                end
        end
 
-       if not is_admin and global_admins then
+       if global_admins then
                if type(global_admins) == "table" then
                        for _,admin in ipairs(global_admins) do
                                if jid_prep(admin) == jid then
-                                       is_admin = true;
-                                       break;
+                                       return true;
                                end
                        end
                elseif global_admins then
@@ -145,10 +143,10 @@ local function is_admin(jid, host)
        end
 
        -- Still not an admin, check with auth provider
-       if not is_admin and host ~= "*" and hosts[host].users and hosts[host].users.is_admin then
-               is_admin = hosts[host].users.is_admin(jid);
+       if host ~= "*" and hosts[host].users and hosts[host].users.is_admin then
+               return hosts[host].users.is_admin(jid);
        end
-       return is_admin or false;
+       return false;
 end
 
 return {