comparison mod_auth_sql/mod_auth_sql.lua @ 1343:7dbde05b48a9

all the things: Remove trailing whitespace
author Florian Zeitz <florob@babelmonkeys.de>
date Tue, 11 Mar 2014 18:44:01 +0100
parents 490cb9161c81
children
comparison
equal deleted inserted replaced
1342:0ae065453dc9 1343:7dbde05b48a9
41 end 41 end
42 end 42 end
43 43
44 do -- process options to get a db connection 44 do -- process options to get a db connection
45 params = params or { driver = "SQLite3" }; 45 params = params or { driver = "SQLite3" };
46 46
47 if params.driver == "SQLite3" then 47 if params.driver == "SQLite3" then
48 params.database = resolve_relative_path(prosody.paths.data or ".", params.database or "prosody.sqlite"); 48 params.database = resolve_relative_path(prosody.paths.data or ".", params.database or "prosody.sqlite");
49 end 49 end
50 50
51 assert(params.driver and params.database, "Both the SQL driver and the database need to be specified"); 51 assert(params.driver and params.database, "Both the SQL driver and the database need to be specified");
52 52
53 assert(connect()); 53 assert(connect());
54 end 54 end
55 55
56 local function getsql(sql, ...) 56 local function getsql(sql, ...)
57 if params.driver == "PostgreSQL" then 57 if params.driver == "PostgreSQL" then
64 if not stmt then module:log("error", "QUERY FAILED: %s %s", err, debug.traceback()); return nil, err; end 64 if not stmt then module:log("error", "QUERY FAILED: %s %s", err, debug.traceback()); return nil, err; end
65 -- run query 65 -- run query
66 local ok, err = stmt:execute(...); 66 local ok, err = stmt:execute(...);
67 if not ok and not test_connection() then error("connection failed"); end 67 if not ok and not test_connection() then error("connection failed"); end
68 if not ok then return nil, err; end 68 if not ok then return nil, err; end
69 69
70 return stmt; 70 return stmt;
71 end 71 end
72 72
73 local function get_password(username) 73 local function get_password(username)
74 local stmt, err = getsql("SELECT `password` FROM `authreg` WHERE `username`=? AND `realm`=?", username, module.host); 74 local stmt, err = getsql("SELECT `password` FROM `authreg` WHERE `username`=? AND `realm`=?", username, module.host);