fix forgot password and otp

This commit is contained in:
Samsularifin01 2026-05-20 00:18:11 +07:00
parent d404368b6c
commit 7d7059d9f8
3 changed files with 12 additions and 11 deletions

View File

@ -2,7 +2,7 @@ class ForgotPasswordResponse {
final String status;
final String message;
final String? token;
final int? expired;
final String? expired;
const ForgotPasswordResponse({
required this.status,
@ -12,12 +12,12 @@ class ForgotPasswordResponse {
});
factory ForgotPasswordResponse.fromJson(Map<String, dynamic> json) {
final dynamic expiredValue = json["expired"];
return ForgotPasswordResponse(
status: json["status"]?.toString() ?? "error",
message: json["message"]?.toString() ?? "",
token: json["token"]?.toString(),
expired: expiredValue is num ? expiredValue.toInt() : null,
expired: json["expired"]?.toString(),
);
}

View File

@ -11,7 +11,7 @@ import 'reset_password_screen.dart';
class OTPScreen extends StatefulWidget {
final String email;
final String serverToken;
final int expiredAt;
final String expiredAt;
const OTPScreen({
super.key,
@ -29,7 +29,7 @@ class _OTPScreenState extends State<OTPScreen> {
final TTSService tts = TTSService();
final ForgotPasswordApiService forgotApi = ForgotPasswordApiService();
late String currentToken;
late int currentExpiredAt;
late String currentExpiredAt;
@override
void initState() {
@ -54,11 +54,12 @@ class _OTPScreenState extends State<OTPScreen> {
return;
}
final int nowSeconds = DateTime.now().millisecondsSinceEpoch ~/ 1000;
if (nowSeconds > currentExpiredAt) {
tts.speak("OTP sudah kedaluwarsa");
return;
}
final DateTime expiredTime = DateTime.parse(currentExpiredAt);
if (DateTime.now().isAfter(expiredTime)) {
tts.speak("OTP sudah kedaluwarsa");
return;
}
if (otp != currentToken) {
tts.speak("OTP tidak sesuai");

View File

@ -5,7 +5,7 @@ class ApiConfig {
static const bool useAndroidEmulator = false;
// Ganti IP ini dengan IP laptop/PC Anda saat menggunakan HP fisik (ADB).
static const String deviceHost = "192.168.18.14:8000";
static const String deviceHost = "192.168.0.31:8000";
static String get baseUrl {
if (Platform.isAndroid && useAndroidEmulator) {