aboutsummaryrefslogtreecommitdiff
path: root/src/mod_register.erl
diff options
context:
space:
mode:
authorBadlop <badlop@process-one.net>2016-06-14 23:35:47 +0200
committerBadlop <badlop@process-one.net>2016-06-14 23:35:47 +0200
commit90046081817cac7225c111bbb6bc7f3f327f35eb (patch)
treef0fac0cc6ede08c18189b1ff3a14c53cd8d461d1 /src/mod_register.erl
parentmod_mam: Fix "assume_mam_usage: if_enabled" (diff)
Check password with jid:resourceprep when registering account (#996)
Diffstat (limited to 'src/mod_register.erl')
-rw-r--r--src/mod_register.erl16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mod_register.erl b/src/mod_register.erl
index 27e484e85..73a999c35 100644
--- a/src/mod_register.erl
+++ b/src/mod_register.erl
@@ -386,6 +386,10 @@ try_set_password(User, Server, Password, IQ, SubEl,
IQ#iq{type = error,
sub_el = [SubEl, ?ERR_INTERNAL_SERVER_ERROR]}
end;
+ error_preparing_password ->
+ ErrText = <<"The password contains unacceptable characters">>,
+ IQ#iq{type = error,
+ sub_el = [SubEl, ?ERRT_NOT_ACCEPTABLE(Lang, ErrText)]};
false ->
ErrText = <<"The password is too weak">>,
IQ#iq{type = error,
@@ -440,6 +444,10 @@ try_register(User, Server, Password, SourceRaw, Lang) ->
{error, ?ERR_INTERNAL_SERVER_ERROR}
end
end;
+ error_preparing_password ->
+ remove_timeout(Source),
+ ErrText = <<"The password contains unacceptable characters">>,
+ {error, ?ERRT_NOT_ACCEPTABLE(Lang, ErrText)};
false ->
remove_timeout(Source),
ErrText = <<"The password is too weak">>,
@@ -636,6 +644,14 @@ process_xdata_submit(El) ->
end.
is_strong_password(Server, Password) ->
+ case jid:resourceprep(Password) of
+ PP when is_binary(PP) ->
+ is_strong_password2(Server, Password);
+ error ->
+ error_preparing_password
+ end.
+
+is_strong_password2(Server, Password) ->
LServer = jid:nameprep(Server),
case gen_mod:get_module_opt(LServer, ?MODULE, password_strength,
fun(N) when is_number(N), N>=0 -> N end,