comparison mod_password_policy/mod_password_policy.lua @ 3350:cb26d04b391c

mod_password_policy: Return error as second result explaining failure reason
author Matthew Wild <mwild1@gmail.com>
date Tue, 09 Oct 2018 14:02:42 +0100
parents 1c14edca74a4
children 662f2722f745
comparison
equal deleted inserted replaced
3349:35dc7c38e362 3350:cb26d04b391c
15 options.length = options.length or 8; 15 options.length = options.length or 8;
16 16
17 local st = require "util.stanza"; 17 local st = require "util.stanza";
18 18
19 function check_password(password) 19 function check_password(password)
20 return #password >= options.length; 20 if #password < options.length then
21 return nil, ("Password is too short (minimum %d characters)"):format(options.length);
22 end
23 return true;
21 end 24 end
22 25
23 function handler(event) 26 function handler(event)
24 local origin, stanza = event.origin, event.stanza; 27 local origin, stanza = event.origin, event.stanza;
25 28