changeset 720:97f6d7c4aaed

mod_auth_joomla: Added config option sql.prefix (default = "jos_").
author Waqas Hussain <waqas20@gmail.com>
date Sat, 23 Jun 2012 00:44:32 +0500
parents 5e71e24e33fc
children 9080b0898b6f
files mod_auth_joomla/mod_auth_joomla.lua
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mod_auth_joomla/mod_auth_joomla.lua	Sat Jun 23 00:42:01 2012 +0500
+++ b/mod_auth_joomla/mod_auth_joomla.lua	Sat Jun 23 00:44:32 2012 +0500
@@ -12,6 +12,7 @@
 
 local connection;
 local params = module:get_option("sql");
+local prefix = params and params.prefix or "jos_";
 
 local resolve_relative_path = require "core.configmanager".resolve_relative_path;
 
@@ -79,7 +80,7 @@
 end
 
 local function get_password(username)
-	local stmt, err = getsql("SELECT `password` FROM `jos_users` WHERE `username`=?", username);
+	local stmt, err = getsql("SELECT `password` FROM `"..prefix.."users` WHERE `username`=?", username);
 	if stmt then
 		for row in stmt:rows(true) do
 			return row.password;
@@ -119,7 +120,7 @@
 end
 function provider.set_password(username, password)
 	local hash = joomlaCreateHash(password);
-	local stmt, err = setsql("UPDATE `jos_users` SET `password`=? WHERE `username`=?", hash, username);
+	local stmt, err = setsql("UPDATE `"..prefix.."users` SET `password`=? WHERE `username`=?", hash, username);
 	return stmt and true, err;
 end
 function provider.create_user(username, password)