From d9fcc97b897642dbdb91df4ebd19ec9c6a53f825 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 7 Jul 2022 09:34:08 +0200 Subject: [PATCH] Bug 28787: Rename the REST API route to /auth/otp/token_delivery Content-Type: text/plain; charset=utf-8 Signed-off-by: Marcel de Rooy --- Koha/REST/V1/Auth.pm | 2 +- api/v1/swagger/paths/auth.yaml | 2 +- api/v1/swagger/swagger.yaml | 4 ++-- koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt | 2 +- t/db_dependent/api/v1/two_factor_auth.t | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Koha/REST/V1/Auth.pm b/Koha/REST/V1/Auth.pm index 43906be177..ae2488f212 100644 --- a/Koha/REST/V1/Auth.pm +++ b/Koha/REST/V1/Auth.pm @@ -231,7 +231,7 @@ sub authenticate_api_request { $cookie_auth = 1; } elsif ($status eq "additional-auth-needed") { - if ( $c->req->url->to_abs->path eq '/api/v1/auth/send_otp_token' ) { + if ( $c->req->url->to_abs->path eq '/api/v1/auth/otp/token_delivery' ) { $user = Koha::Patrons->find( $session->param('number') ); $cookie_auth = 1; } else { diff --git a/api/v1/swagger/paths/auth.yaml b/api/v1/swagger/paths/auth.yaml index 43b0decbb5..c147d0549d 100644 --- a/api/v1/swagger/paths/auth.yaml +++ b/api/v1/swagger/paths/auth.yaml @@ -1,5 +1,5 @@ --- -/auth/send_otp_token: +/auth/otp/token_delivery: post: x-mojo-to: TwoFactorAuth#send_otp_token operationId: send_otp_token diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml index 1b16b96003..a67af05640 100644 --- a/api/v1/swagger/swagger.yaml +++ b/api/v1/swagger/swagger.yaml @@ -97,8 +97,8 @@ paths: $ref: "./paths/advancededitormacros.yaml#/~1advanced_editor~1macros~1{advancededitormacro_id}" "/article_requests/{article_request_id}": $ref: "./paths/article_requests.yaml#/~1article_requests~1{article_request_id}" - /auth/send_otp_token: - $ref: paths/auth.yaml#/~1auth~1send_otp_token + /auth/otp/token_delivery: + $ref: paths/auth.yaml#/~1auth~1otp~1token_delivery "/biblios/{biblio_id}": $ref: "./paths/biblios.yaml#/~1biblios~1{biblio_id}" "/biblios/{biblio_id}/checkouts": diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt index e188d5f268..41995bf423 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt @@ -198,7 +198,7 @@ $("#email_success").hide(); $("#email_error").hide(); $.ajax({ - url: '/api/v1/auth/send_otp_token', + 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.") diff --git a/t/db_dependent/api/v1/two_factor_auth.t b/t/db_dependent/api/v1/two_factor_auth.t index 8a55e61e0a..ddda4fd0a0 100755 --- a/t/db_dependent/api/v1/two_factor_auth.t +++ b/t/db_dependent/api/v1/two_factor_auth.t @@ -58,7 +58,7 @@ subtest 'send_otp_token' => sub { $session->param( 'lasttime', time() ); $session->flush; - my $tx = $t->ua->build_tx( POST => "/api/v1/auth/send_otp_token" ); + my $tx = $t->ua->build_tx( POST => "/api/v1/auth/otp/token_delivery" ); $tx->req->cookies( { name => 'CGISESSID', value => $session->id } ); $tx->req->env( { REMOTE_ADDR => $remote_address } ); @@ -85,7 +85,7 @@ subtest 'send_otp_token' => sub { $patron->email(undef); $patron->store; - $tx = $t->ua->build_tx( POST => "/api/v1/auth/send_otp_token" ); + $tx = $t->ua->build_tx( POST => "/api/v1/auth/otp/token_delivery" ); $tx->req->cookies( { name => 'CGISESSID', value => $session->id } ); $tx->req->env( { REMOTE_ADDR => $remote_address } ); @@ -93,7 +93,7 @@ subtest 'send_otp_token' => sub { $t->request_ok($tx)->status_is(400)->json_is({ error => 'email_not_sent' }); $patron->email('to@example.org')->store; - $tx = $t->ua->build_tx( POST => "/api/v1/auth/send_otp_token" ); + $tx = $t->ua->build_tx( POST => "/api/v1/auth/otp/token_delivery" ); $tx->req->cookies( { name => 'CGISESSID', value => $session->id } ); $tx->req->env( { REMOTE_ADDR => $remote_address } ); -- 2.20.1