Changeset

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 3349:35dc7c38e362
children 3351:662f2722f745
files mod_password_policy/mod_password_policy.lua
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_password_policy/mod_password_policy.lua	Sun Oct 07 03:39:35 2018 +0200
+++ b/mod_password_policy/mod_password_policy.lua	Tue Oct 09 14:02:42 2018 +0100
@@ -17,7 +17,10 @@
 local st = require "util.stanza";
 
 function check_password(password)
-	return #password >= options.length;
+	if #password < options.length then
+		return nil, ("Password is too short (minimum %d characters)"):format(options.length);
+	end
+	return true;
 end
 
 function handler(event)