新增手机号码和手机找回密码优化功能

(cherry picked from commit 577dd6eab9ee403ce78850f71e11a5f48dc265b5)
This commit is contained in:
Rust 2025-11-01 00:42:10 -07:00 committed by speakeloudest
parent 3f838d224c
commit f71575ee91
2 changed files with 33 additions and 7 deletions

View File

@ -25,8 +25,11 @@ abstract class Api {
///
static const String kr_deleteAccount = "/v1/public/user/delete_account";
/// -
static const String kr_setNewPsdByForgetPsd = "/v1/app/auth/reset_password";
/// -
static const String kr_resetPassword = "/v1/auth/reset";
/// -
static const String kr_resetPasswordByTelephone = "/v1/auth/reset/telephone";
/// /
static const String kr_nodeList = "/v1/public/subscribe/node/list";

View File

@ -285,17 +285,40 @@ class KRAuthApi {
return right("");
}
/// -
Future<Either<HttpError, String>> kr_setNewPsdByForgetPsd(
/// -
Future<Either<HttpError, String>> kr_resetPassword(
String email, String code, String password) async {
final Map<String, dynamic> data = <String, dynamic>{};
data['identifier'] = KRDeviceInfoService().deviceId ?? 'unknown';
data['email'] = email;
data['password'] = password;
data["code"] = code;
data["identifier"] = KRDeviceInfoService().deviceId ?? 'unknown';
data['code'] = code;
data['cf_token'] = ""; // Cloudflare token
BaseResponse<KRLoginData> baseResponse = await HttpUtil.getInstance()
.request<KRLoginData>(Api.kr_setNewPsdByForgetPsd, data,
.request<KRLoginData>(Api.kr_resetPassword, data,
method: HttpMethod.POST, isShowLoading: true);
if (!baseResponse.isSuccess) {
return left(
HttpError(msg: baseResponse.retMsg, code: baseResponse.retCode));
}
return right(baseResponse.model.kr_token.toString());
}
/// -
Future<Either<HttpError, String>> kr_resetPasswordByTelephone(
String telephone, String areaCode, String code, String password) async {
final Map<String, dynamic> data = <String, dynamic>{};
data['identifier'] = KRDeviceInfoService().deviceId ?? 'unknown';
data['telephone'] = telephone;
data['telephone_area_code'] = areaCode;
data['password'] = password;
data['code'] = code;
data['cf_token'] = ""; // Cloudflare token
BaseResponse<KRLoginData> baseResponse = await HttpUtil.getInstance()
.request<KRLoginData>(Api.kr_resetPasswordByTelephone, data,
method: HttpMethod.POST, isShowLoading: true);
if (!baseResponse.isSuccess) {
return left(