Software / code / prosody
Comparison
core/usermanager.lua @ 450:e04c4052742c
Merge from waqas
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 27 Nov 2008 23:36:49 +0000 |
| parent | 449:c0a4a1e63d70 |
| child | 519:cccd610a0ef9 |
comparison
equal
deleted
inserted
replaced
| 444:77485b9b840c | 450:e04c4052742c |
|---|---|
| 17 else | 17 else |
| 18 return nil, "Auth failed. Invalid username or password."; | 18 return nil, "Auth failed. Invalid username or password."; |
| 19 end | 19 end |
| 20 end | 20 end |
| 21 -- must do md5 | 21 -- must do md5 |
| 22 if not hashes.md5 then | |
| 23 return nil, "Server misconfiguration, the md5 library is not available."; | |
| 24 end | |
| 25 -- make credentials md5 | 22 -- make credentials md5 |
| 26 local pwd = credentials.password; | 23 local pwd = credentials.password; |
| 27 if not pwd then pwd = credentials.md5; else pwd = hashes.md5(pwd); end | 24 if not pwd then pwd = credentials.md5; else pwd = hashes.md5(pwd, true); end |
| 28 -- make password md5 | 25 -- make password md5 |
| 29 if method == "PLAIN" then | 26 if method == "PLAIN" then |
| 30 password = hashes.md5(password or ""); | 27 password = hashes.md5(password or "", true); |
| 31 elseif method ~= "DIGEST-MD5" then | 28 elseif method ~= "DIGEST-MD5" then |
| 32 return nil, "Unsupported auth method"; | 29 return nil, "Unsupported auth method"; |
| 33 end | 30 end |
| 34 -- compare | 31 -- compare |
| 35 if password == pwd then | 32 if password == pwd then |
| 47 return datamanager.store(username, host, "accounts", {password = password}); | 44 return datamanager.store(username, host, "accounts", {password = password}); |
| 48 end | 45 end |
| 49 | 46 |
| 50 function get_supported_methods(host) | 47 function get_supported_methods(host) |
| 51 local methods = {["PLAIN"] = true}; -- TODO this should be taken from the config | 48 local methods = {["PLAIN"] = true}; -- TODO this should be taken from the config |
| 52 if hashes.md5 then | 49 methods["DIGEST-MD5"] = true; |
| 53 methods["DIGEST-MD5"] = true; | |
| 54 end | |
| 55 return methods; | 50 return methods; |
| 56 end | 51 end |
| 57 | 52 |
| 58 return _M; | 53 return _M; |