Mercurial > prosody-modules
changeset 426:6f2e37d0a1b0
mod_auth_wordpress: Allow table prefix to be configured
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 11 Sep 2011 22:53:23 +0200 |
parents | 34eb9df9e37f |
children | 35b3ea156156 |
files | mod_auth_wordpress/mod_auth_wordpress.lua |
diffstat | 1 files changed, 3 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_auth_wordpress/mod_auth_wordpress.lua Sun Sep 11 22:05:13 2011 +0200 +++ b/mod_auth_wordpress/mod_auth_wordpress.lua Sun Sep 11 22:53:23 2011 +0200 @@ -13,6 +13,7 @@ local connection; local params = module:get_option("sql"); +local table_prefix = module:get_option_string("wordpress_table_prefix", "wp_"); local resolve_relative_path = require "core.configmanager".resolve_relative_path; @@ -80,7 +81,7 @@ end local function get_password(username) - local stmt, err = getsql("SELECT `user_pass` FROM `wp_users` WHERE `user_login`=?", username); + local stmt, err = getsql("SELECT `user_pass` FROM `"..table_prefix.."users` WHERE `user_login`=?", username); if stmt then for row in stmt:rows(true) do return row.user_password; @@ -190,7 +191,7 @@ end function provider.set_password(username, password) local hash = wordpressCreateHash(password); - local stmt, err = setsql("UPDATE `wp_users` SET `user_pass`=? WHERE `user_login`=?", hash, username); + local stmt, err = setsql("UPDATE `"..table_prefix.."users` SET `user_pass`=? WHERE `user_login`=?", hash, username); return stmt and true, err; end function provider.create_user(username, password)