@@ -, +, @@ --- C4/Auth.pm | 2 ++ .../intranet-tmpl/prog/en/modules/auth.tt | 32 +++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) --- a/C4/Auth.pm +++ a/C4/Auth.pm @@ -1415,9 +1415,11 @@ sub checkauth { $template->param( OpacPublic => C4::Context->preference("OpacPublic") ); $template->param( loginprompt => 1 ) unless $info{'nopermission'}; if ( $auth_state eq 'additional-auth-needed' ) { + my $patron = Koha::Patrons->find( { userid => $userid } ); $template->param( TwoFA_prompt => 1, invalid_otp_token => $invalid_otp_token, + notice_email_address => $patron->notice_email_address, # We could also pass logged_in_user if necessary ); } --- a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt @@ -195,22 +195,26 @@ $("#send_otp").on("click", function(e){ e.preventDefault(); + [% UNLESS notice_email_address %] + alert("Cannot send the notice, you don't have an email address defined.") + [% ELSE %] $("#email_success").hide(); $("#email_error").hide(); - $.ajax({ - url: '/api/v1/auth/otp/token_delivery', - type: 'POST', - success: function(data){ - let message = _("The code has been sent by email, please check your inbox.") - $("#email_success").show().html(message); - }, - error: function(data){ - let error = data.responseJSON && data.responseJSON.error == "email_not_sent" - ? _("Email not sent, maybe you don't have an email address defined?") - : _("Email not sent"); - $("#email_error").show().html(error); - } - }); + $.ajax({ + url: '/api/v1/auth/otp/token_delivery', + type: 'POST', + success: function(data){ + let message = _("The code has been sent by email, please check your inbox.") + $("#email_success").show().html(message); + }, + error: function(data){ + let error = data.responseJSON && data.responseJSON.error == "email_not_sent" + ? _("Email not sent, please contact the Koha administrator") + : _("Something wrong happened, please contact the Koha administrator"); + $("#email_error").show().html(error); + } + }); + [% END %] }); }); --