mirror of https://github.com/sipwise/prosody.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.5 KiB
38 lines
1.5 KiB
From: Andreas Granig <agranig@sipwise.com>
|
|
Date: Wed, 7 Aug 2013 22:34:34 +0200
|
|
Subject: sipwise custom auth
|
|
|
|
---
|
|
plugins/mod_auth_sql/mod_auth_sql.lua | 9 ++++++---
|
|
1 file changed, 6 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/plugins/mod_auth_sql/mod_auth_sql.lua b/plugins/mod_auth_sql/mod_auth_sql.lua
|
|
index 2947a91..631768d 100644
|
|
--- a/plugins/mod_auth_sql/mod_auth_sql.lua
|
|
+++ b/plugins/mod_auth_sql/mod_auth_sql.lua
|
|
@@ -71,10 +71,13 @@ local function getsql(sql, ...)
|
|
end
|
|
|
|
local function get_password(username)
|
|
- local stmt, err = getsql("SELECT `password` FROM `authreg` WHERE `username`=? AND `realm`=?", username, module.host);
|
|
+ local stmt, err = getsql("SELECT `s`.`password`, COALESCE(`p`.`value`, 0) AS `locklevel` FROM `subscriber` AS `s` LEFT JOIN usr_preferences AS `p` ON `p`.`username` = `s`.`username` AND `p`.`domain` = `s`.`domain` AND `p`.`attribute` = 'lock' WHERE `s`.`username`= ? AND lower(`s`.`domain`)= ?", username, module.host);
|
|
if stmt then
|
|
for row in stmt:rows(true) do
|
|
- return row.password;
|
|
+ local locklevel = 0 + row.locklevel;
|
|
+ if locklevel < 4 then
|
|
+ return row.password;
|
|
+ end
|
|
end
|
|
end
|
|
end
|
|
@@ -109,7 +112,7 @@ function provider.get_sasl_handler()
|
|
end
|
|
|
|
function provider.users()
|
|
- local stmt, err = getsql("SELECT `username` FROM `authreg` WHERE `realm`=?", module.host);
|
|
+ local stmt, err = getsql("SELECT `username` FROM `subscriber` WHERE lower(`domain`)=?", module.host);
|
|
if stmt then
|
|
local next, state = stmt:rows(true)
|
|
return function()
|