Software /
code /
prosody
Changeset
9980:73a447249fe4
mod_mimicking: Prevents registration of confusable usernames (by Florob) (fixes #1347)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 06 Aug 2012 15:35:27 +0200 |
parents | 9979:b06f6ff878ee |
children | 9981:8758febbaca2 |
files | CHANGES plugins/mod_mimicking.lua |
diffstat | 2 files changed, 50 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGES Mon Apr 29 15:53:52 2019 +0200 +++ b/CHANGES Mon Aug 06 15:35:27 2012 +0200 @@ -7,6 +7,7 @@ - CSI improvements - mod\_limits: Exempted JIDs - Archive quotas +- mod\_mimicking 0.11.0 ======
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/mod_mimicking.lua Mon Aug 06 15:35:27 2012 +0200 @@ -0,0 +1,49 @@ +-- Prosody IM +-- Copyright (C) 2012 Florian Zeitz +-- +-- This project is MIT/X11 licensed. Please see the +-- COPYING file in the source package for more information. +-- + +local skeleton = require "util.confusable".skeleton; +local datamanager = require "util.datamanager"; +local usage = require "util.prosodyctl".show_usage; +local warn = require "util.prosodyctl".show_warning; +local users = require "usermanager".users; + +module:hook("user-registered", function(user) + datamanager.store(skeleton(user.username), user.host, "skeletons", {username = user.username}); +end); + +module:hook("user-deregistered", function(user) + datamanager.store(skeleton(user.username), user.host, "skeletons", nil); +end); + +module:hook("registration-attempt", function(user) + if datamanager.load(skeleton(user.username), user.host, "skeletons") then + user.allowed = false; + end +end); + +function module.command(arg) + if (arg[1] ~= "bootstrap" or not arg[2]) then + usage("mod_mimicking bootstrap <host>", "Initialize skeleton database"); + return; + end + + local host = arg[2]; + + local host_session = prosody.hosts[host]; + if not host_session then + return "No such host"; + end + local provider = host_session.users; + if not(provider) or provider.name == "null" then + usermanager.initialize_host(host); + end + storagemanager.initialize_host(host); + + for user in users(host) do + datamanager.store(skeleton(user), host, "skeletons", {username = user}); + end +end