commit 4b98b693d696d90f30f0a6546b0e1f4bc181a5f2
parent d783cdc82b5e1c1c90cc13ee15e04381935fcbf8
Author: Sebastian <sebasjm@gmail.com>
Date: Sat, 21 Oct 2023 20:23:11 -0300
add missing response code
Diffstat:
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/packages/taler-util/src/http-client/bank-core.ts b/packages/taler-util/src/http-client/bank-core.ts
@@ -166,7 +166,7 @@ export class TalerCoreBankHttpClient {
*
*/
async updatePassword(auth: UserAndToken, body: TalerCorebankApi.AccountPasswordChange) {
- const url = new URL(`accounts/${auth.username}`, this.baseUrl);
+ const url = new URL(`accounts/${auth.username}/auth`, this.baseUrl);
const resp = await this.httpLib.fetch(url.href, {
method: "PATCH",
body,
@@ -179,6 +179,8 @@ export class TalerCoreBankHttpClient {
//FIXME: missing in docs
case HttpStatusCode.NotFound: return opKnownFailure("not-found", resp);
//FIXME: missing in docs
+ case HttpStatusCode.Unauthorized: return opKnownFailure("no-rights", resp);
+ //FIXME: missing in docs
case HttpStatusCode.Forbidden: return opKnownFailure("unauthorized", resp);
default: return opUnknownFailure(resp, await resp.text())
}
@@ -241,6 +243,8 @@ export class TalerCoreBankHttpClient {
});
switch (resp.status) {
case HttpStatusCode.Ok: return opSuccess(resp, codecForAccountData())
+ //FIXME: missing in docs (401 when not found?)
+ case HttpStatusCode.Unauthorized: return opKnownFailure("not-found", resp);
//FIXME: missing in docs
case HttpStatusCode.NotFound: return opKnownFailure("not-found", resp);
//FIXME: missing in docs
diff --git a/packages/taler-util/src/http-client/types.ts b/packages/taler-util/src/http-client/types.ts
@@ -1017,9 +1017,12 @@ export namespace TalerCorebankApi {
export interface AccountPasswordChange {
-
+ // FIXME: missing in docs
// New password.
new_password: string;
+ // Old password. If present, chec that the old password matches.
+ // Optional for admin account.
+ old_password?: string;
}
export interface PublicAccountsResponse {
diff --git a/packages/web-util/src/utils/http-impl.browser.ts b/packages/web-util/src/utils/http-impl.browser.ts
@@ -69,7 +69,7 @@ export class BrowserHttpLib implements HttpRequestLibrary {
}
let myBody: ArrayBuffer | undefined =
- requestMethod === "POST" || requestMethod === "PUT"
+ requestMethod === "POST" || requestMethod === "PUT" || requestMethod === "PATCH"
? encodeBody(requestBody)
: undefined;