From f67d7da123014b971da68156957723baeb7fa720 Mon Sep 17 00:00:00 2001 From: nevehallon Date: Tue, 7 Nov 2023 15:14:09 +0200 Subject: [PATCH] fix: otp --- bageldb-flutter/CHANGELOG.md | 4 ++++ bageldb-flutter/lib/src/bagel_db_users.dart | 2 +- bageldb-flutter/pubspec.yaml | 2 +- bageldb-flutter/test/bagel_db_test.dart | 6 ++---- bageldb-js/src/users.ts | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/bageldb-flutter/CHANGELOG.md b/bageldb-flutter/CHANGELOG.md index 958487c..7ba8282 100644 --- a/bageldb-flutter/CHANGELOG.md +++ b/bageldb-flutter/CHANGELOG.md @@ -177,3 +177,7 @@ # 0.2.24 - Add: `updatePassword()` method + +# 0.2.24 + +- Add: `validateOtp()` t query param to ensure the otp is valid diff --git a/bageldb-flutter/lib/src/bagel_db_users.dart b/bageldb-flutter/lib/src/bagel_db_users.dart index 5f4d635..11f708a 100644 --- a/bageldb-flutter/lib/src/bagel_db_users.dart +++ b/bageldb-flutter/lib/src/bagel_db_users.dart @@ -152,7 +152,7 @@ class BagelUsersRequest { String? _nonce = _getOtpRequestNonce() ?? nonce; if (_nonce.isEmpty) throw ("Couldn't find OTP nonce, please run requestOTP first"); - String url = '$authEndpoint/user/otp/verify/$_nonce'; + String url = '$authEndpoint/user/otp/verify/$_nonce?t=${DateTime.now()}'; Map body = {"otp": otp}; try { Response res = await dio.post(url, data: body); diff --git a/bageldb-flutter/pubspec.yaml b/bageldb-flutter/pubspec.yaml index d5b00e5..5531022 100644 --- a/bageldb-flutter/pubspec.yaml +++ b/bageldb-flutter/pubspec.yaml @@ -1,6 +1,6 @@ name: bagel_db description: Dart plugin to retrieve and update data on BagelDB. This library allows you to build a backend in a matter of minutes, make REST API requests and manage your content easily -version: 0.2.24 +version: 0.2.25 homepage: https://www.bageldb.com/ environment: diff --git a/bageldb-flutter/test/bagel_db_test.dart b/bageldb-flutter/test/bagel_db_test.dart index 3642d5e..b44e53f 100644 --- a/bageldb-flutter/test/bagel_db_test.dart +++ b/bageldb-flutter/test/bagel_db_test.dart @@ -61,10 +61,8 @@ updateUserPasswordTest() { group('phone auth test', () { test('update user password test', () async { try { - final res = await db.bagelUsersRequest.updatePassword( - testPhone, - "123123", - ); + final res = + await db.bagelUsersRequest.updatePassword(testPhone, testPassword); print({"res": res}); expect(res, isNotNull); } catch (e) { diff --git a/bageldb-js/src/users.ts b/bageldb-js/src/users.ts index c5e8492..7fe4579 100644 --- a/bageldb-js/src/users.ts +++ b/bageldb-js/src/users.ts @@ -102,7 +102,7 @@ export default class BagelUsersRequest { */ async validateOtp(otp: string) { const nonce = await this._getOtpRequestNonce(); - const url = `${AUTH_ENDPOINT}/user/otp/verify/${nonce}`; + const url = `${AUTH_ENDPOINT}/user/otp/verify/${nonce}?t=${Date.now()}`; const body = { otp }; try { const res = await this.axios.post(url, body);