Software /
code /
prosody
Comparison
plugins/mod_auth_internal_plain.lua @ 5779:70bb0df1ffe7
mod_auth_internal_plain: Remove redundant hostname from log messages
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 10 Aug 2013 20:06:51 +0200 |
parent | 5776:bd0ff8ae98a8 |
child | 5780:bc3bf4ded7e4 |
comparison
equal
deleted
inserted
replaced
5778:8ea6fa8459e3 | 5779:70bb0df1ffe7 |
---|---|
17 -- define auth provider | 17 -- define auth provider |
18 local provider = {}; | 18 local provider = {}; |
19 log("debug", "initializing internal_plain authentication provider for host '%s'", host); | 19 log("debug", "initializing internal_plain authentication provider for host '%s'", host); |
20 | 20 |
21 function provider.test_password(username, password) | 21 function provider.test_password(username, password) |
22 log("debug", "test password for user %s at host %s", username, host); | 22 log("debug", "test password for user '%s'", username); |
23 local credentials = accounts:get(username) or {}; | 23 local credentials = accounts:get(username) or {}; |
24 | 24 |
25 if password == credentials.password then | 25 if password == credentials.password then |
26 return true; | 26 return true; |
27 else | 27 else |
28 return nil, "Auth failed. Invalid username or password."; | 28 return nil, "Auth failed. Invalid username or password."; |
29 end | 29 end |
30 end | 30 end |
31 | 31 |
32 function provider.get_password(username) | 32 function provider.get_password(username) |
33 log("debug", "get_password for username '%s' at host '%s'", username, host); | 33 log("debug", "get_password for username '%s'", username); |
34 return (accounts:get(username) or {}).password; | 34 return (accounts:get(username) or {}).password; |
35 end | 35 end |
36 | 36 |
37 function provider.set_password(username, password) | 37 function provider.set_password(username, password) |
38 local account = accounts:get(username); | 38 local account = accounts:get(username); |
44 end | 44 end |
45 | 45 |
46 function provider.user_exists(username) | 46 function provider.user_exists(username) |
47 local account = accounts:get(username); | 47 local account = accounts:get(username); |
48 if not account then | 48 if not account then |
49 log("debug", "account not found for username '%s' at host '%s'", username, host); | 49 log("debug", "account not found for username '%s'", username); |
50 return nil, "Auth failed. Invalid username"; | 50 return nil, "Auth failed. Invalid username"; |
51 end | 51 end |
52 return true; | 52 return true; |
53 end | 53 end |
54 | 54 |