mirror of
https://github.com/processone/ejabberd
synced 2025-10-03 17:59:31 +02:00
Improve logging of external authentication failures
This commit is contained in:
parent
5522403e8e
commit
61ae0ff02c
1 changed files with 9 additions and 8 deletions
|
@ -64,27 +64,27 @@ check_password(User, AuthzId, Server, Password) ->
|
||||||
set_password(User, Server, Password) ->
|
set_password(User, Server, Password) ->
|
||||||
case extauth:set_password(User, Server, Password) of
|
case extauth:set_password(User, Server, Password) of
|
||||||
Res when is_boolean(Res) -> ok;
|
Res when is_boolean(Res) -> ok;
|
||||||
{error, Reason} -> failure(Reason)
|
{error, Reason} -> failure(User, Server, ?FUNCTION_NAME, Reason)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
try_register(User, Server, Password) ->
|
try_register(User, Server, Password) ->
|
||||||
case extauth:try_register(User, Server, Password) of
|
case extauth:try_register(User, Server, Password) of
|
||||||
true -> ok;
|
true -> ok;
|
||||||
false -> {error, not_allowed};
|
false -> {error, not_allowed};
|
||||||
{error, Reason} -> failure(Reason)
|
{error, Reason} -> failure(User, Server, ?FUNCTION_NAME, Reason)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
user_exists(User, Server) ->
|
user_exists(User, Server) ->
|
||||||
case extauth:user_exists(User, Server) of
|
case extauth:user_exists(User, Server) of
|
||||||
Res when is_boolean(Res) -> Res;
|
Res when is_boolean(Res) -> Res;
|
||||||
{error, Reason} -> failure(Reason)
|
{error, Reason} -> failure(User, Server, ?FUNCTION_NAME, Reason)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
remove_user(User, Server) ->
|
remove_user(User, Server) ->
|
||||||
case extauth:remove_user(User, Server) of
|
case extauth:remove_user(User, Server) of
|
||||||
false -> {error, not_allowed};
|
false -> {error, not_allowed};
|
||||||
true -> ok;
|
true -> ok;
|
||||||
{error, Reason} -> failure(Reason)
|
{error, Reason} -> failure(User, Server, ?FUNCTION_NAME, Reason)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
check_password_extauth(User, _AuthzId, Server, Password) ->
|
check_password_extauth(User, _AuthzId, Server, Password) ->
|
||||||
|
@ -92,16 +92,17 @@ check_password_extauth(User, _AuthzId, Server, Password) ->
|
||||||
case extauth:check_password(User, Server, Password) of
|
case extauth:check_password(User, Server, Password) of
|
||||||
Res when is_boolean(Res) -> Res;
|
Res when is_boolean(Res) -> Res;
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
failure(Reason),
|
failure(User, Server, ?FUNCTION_NAME, Reason),
|
||||||
false
|
false
|
||||||
end;
|
end;
|
||||||
true ->
|
true ->
|
||||||
false
|
false
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec failure(any()) -> {error, db_failure}.
|
-spec failure(binary(), binary(), atom(), any()) -> {error, db_failure}.
|
||||||
failure(Reason) ->
|
failure(User, Server, Fun, Reason) ->
|
||||||
?ERROR_MSG("External authentication program failure: ~p", [Reason]),
|
?ERROR_MSG("External authentication program failed when calling "
|
||||||
|
"'~s' for ~s@~s: ~p", [Fun, User, Server, Reason]),
|
||||||
{error, db_failure}.
|
{error, db_failure}.
|
||||||
|
|
||||||
opt_type(extauth_cache) ->
|
opt_type(extauth_cache) ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue