Software / code / prosody
Comparison
core/usermanager.lua @ 2934:060bb8217fea
usermanager: Added function set_password.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Wed, 24 Mar 2010 00:03:31 +0500 |
| parent | 2929:1e4e314bef33 |
| child | 2987:0acfae4da199 |
| child | 3064:596303990c7c |
comparison
equal
deleted
inserted
replaced
| 2931:de4daf300f19 | 2934:060bb8217fea |
|---|---|
| 53 | 53 |
| 54 function get_password(username, host) | 54 function get_password(username, host) |
| 55 if is_cyrus(host) then return nil, "Passwords unavailable for Cyrus SASL."; end | 55 if is_cyrus(host) then return nil, "Passwords unavailable for Cyrus SASL."; end |
| 56 return (datamanager.load(username, host, "accounts") or {}).password | 56 return (datamanager.load(username, host, "accounts") or {}).password |
| 57 end | 57 end |
| 58 function set_password(username, host, password) | |
| 59 if is_cyrus(host) then return nil, "Passwords unavailable for Cyrus SASL."; end | |
| 60 local account = datamanager.load(username, host, "accounts"); | |
| 61 if account then | |
| 62 account.password = password; | |
| 63 return datamanager.store(username, host, "accounts", account); | |
| 64 end | |
| 65 return nil, "Account not available."; | |
| 66 end | |
| 58 | 67 |
| 59 function user_exists(username, host) | 68 function user_exists(username, host) |
| 60 if is_cyrus(host) then return true; end | 69 if is_cyrus(host) then return true; end |
| 61 return datamanager.load(username, host, "accounts") ~= nil; -- FIXME also check for empty credentials | 70 return datamanager.load(username, host, "accounts") ~= nil; -- FIXME also check for empty credentials |
| 62 end | 71 end |