feat: add hook to check decoded JWT after success authentication (#3446)

This commit is contained in:
Pouriya 2020-12-14 10:44:58 +03:30 committed by GitHub
parent d64e453364
commit a76531b90b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -102,10 +102,11 @@ check_jwt_token(User, Server, Token) ->
error ->
false;
{ok, SJID} ->
try
JID = jid:decode(SJID),
(JID#jid.luser == User) andalso
(JID#jid.lserver == Server)
try jid:decode(SJID) of
JID ->
(JID#jid.luser == User) andalso
(JID#jid.lserver == Server) andalso
ejabberd_hooks:run_fold(check_decoded_jwt, Server, true, [Fields, Signature, User])
catch error:{bad_jid, _} ->
false
end