Bug 28787: Don't request a token if no email address defined
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Sponsored-by: Rijksmuseum, Netherlands Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
950cfa1173
commit
c52eb53c69
|
|
@ -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
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 %]
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue