Software / code / prosody-modules
Comparison
mod_auth_joomla/mod_auth_joomla.lua @ 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 |
| parent | 719:5e71e24e33fc |
| child | 814:881ec9919144 |
comparison
equal
deleted
inserted
replaced
| 719:5e71e24e33fc | 720:97f6d7c4aaed |
|---|---|
| 10 local md5 = require "util.hashes".md5; | 10 local md5 = require "util.hashes".md5; |
| 11 local uuid_gen = require "util.uuid".generate; | 11 local uuid_gen = require "util.uuid".generate; |
| 12 | 12 |
| 13 local connection; | 13 local connection; |
| 14 local params = module:get_option("sql"); | 14 local params = module:get_option("sql"); |
| 15 local prefix = params and params.prefix or "jos_"; | |
| 15 | 16 |
| 16 local resolve_relative_path = require "core.configmanager".resolve_relative_path; | 17 local resolve_relative_path = require "core.configmanager".resolve_relative_path; |
| 17 | 18 |
| 18 local function test_connection() | 19 local function test_connection() |
| 19 if not connection then return nil; end | 20 if not connection then return nil; end |
| 77 if not stmt then return stmt, err; end | 78 if not stmt then return stmt, err; end |
| 78 return stmt:affected(); | 79 return stmt:affected(); |
| 79 end | 80 end |
| 80 | 81 |
| 81 local function get_password(username) | 82 local function get_password(username) |
| 82 local stmt, err = getsql("SELECT `password` FROM `jos_users` WHERE `username`=?", username); | 83 local stmt, err = getsql("SELECT `password` FROM `"..prefix.."users` WHERE `username`=?", username); |
| 83 if stmt then | 84 if stmt then |
| 84 for row in stmt:rows(true) do | 85 for row in stmt:rows(true) do |
| 85 return row.password; | 86 return row.password; |
| 86 end | 87 end |
| 87 end | 88 end |
| 117 function provider.get_password(username) | 118 function provider.get_password(username) |
| 118 return nil, "Getting password is not supported."; | 119 return nil, "Getting password is not supported."; |
| 119 end | 120 end |
| 120 function provider.set_password(username, password) | 121 function provider.set_password(username, password) |
| 121 local hash = joomlaCreateHash(password); | 122 local hash = joomlaCreateHash(password); |
| 122 local stmt, err = setsql("UPDATE `jos_users` SET `password`=? WHERE `username`=?", hash, username); | 123 local stmt, err = setsql("UPDATE `"..prefix.."users` SET `password`=? WHERE `username`=?", hash, username); |
| 123 return stmt and true, err; | 124 return stmt and true, err; |
| 124 end | 125 end |
| 125 function provider.create_user(username, password) | 126 function provider.create_user(username, password) |
| 126 return nil, "Account creation/modification not supported."; | 127 return nil, "Account creation/modification not supported."; |
| 127 end | 128 end |