fix forgot password and otp
This commit is contained in:
parent
d404368b6c
commit
7d7059d9f8
|
|
@ -2,7 +2,7 @@ class ForgotPasswordResponse {
|
||||||
final String status;
|
final String status;
|
||||||
final String message;
|
final String message;
|
||||||
final String? token;
|
final String? token;
|
||||||
final int? expired;
|
final String? expired;
|
||||||
|
|
||||||
const ForgotPasswordResponse({
|
const ForgotPasswordResponse({
|
||||||
required this.status,
|
required this.status,
|
||||||
|
|
@ -12,12 +12,12 @@ class ForgotPasswordResponse {
|
||||||
});
|
});
|
||||||
|
|
||||||
factory ForgotPasswordResponse.fromJson(Map<String, dynamic> json) {
|
factory ForgotPasswordResponse.fromJson(Map<String, dynamic> json) {
|
||||||
final dynamic expiredValue = json["expired"];
|
|
||||||
return ForgotPasswordResponse(
|
return ForgotPasswordResponse(
|
||||||
status: json["status"]?.toString() ?? "error",
|
status: json["status"]?.toString() ?? "error",
|
||||||
message: json["message"]?.toString() ?? "",
|
message: json["message"]?.toString() ?? "",
|
||||||
token: json["token"]?.toString(),
|
token: json["token"]?.toString(),
|
||||||
expired: expiredValue is num ? expiredValue.toInt() : null,
|
expired: json["expired"]?.toString(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import 'reset_password_screen.dart';
|
||||||
class OTPScreen extends StatefulWidget {
|
class OTPScreen extends StatefulWidget {
|
||||||
final String email;
|
final String email;
|
||||||
final String serverToken;
|
final String serverToken;
|
||||||
final int expiredAt;
|
final String expiredAt;
|
||||||
|
|
||||||
const OTPScreen({
|
const OTPScreen({
|
||||||
super.key,
|
super.key,
|
||||||
|
|
@ -29,7 +29,7 @@ class _OTPScreenState extends State<OTPScreen> {
|
||||||
final TTSService tts = TTSService();
|
final TTSService tts = TTSService();
|
||||||
final ForgotPasswordApiService forgotApi = ForgotPasswordApiService();
|
final ForgotPasswordApiService forgotApi = ForgotPasswordApiService();
|
||||||
late String currentToken;
|
late String currentToken;
|
||||||
late int currentExpiredAt;
|
late String currentExpiredAt;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
|
@ -54,11 +54,12 @@ class _OTPScreenState extends State<OTPScreen> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int nowSeconds = DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
final DateTime expiredTime = DateTime.parse(currentExpiredAt);
|
||||||
if (nowSeconds > currentExpiredAt) {
|
|
||||||
tts.speak("OTP sudah kedaluwarsa");
|
if (DateTime.now().isAfter(expiredTime)) {
|
||||||
return;
|
tts.speak("OTP sudah kedaluwarsa");
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (otp != currentToken) {
|
if (otp != currentToken) {
|
||||||
tts.speak("OTP tidak sesuai");
|
tts.speak("OTP tidak sesuai");
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ class ApiConfig {
|
||||||
static const bool useAndroidEmulator = false;
|
static const bool useAndroidEmulator = false;
|
||||||
|
|
||||||
// Ganti IP ini dengan IP laptop/PC Anda saat menggunakan HP fisik (ADB).
|
// 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 {
|
static String get baseUrl {
|
||||||
if (Platform.isAndroid && useAndroidEmulator) {
|
if (Platform.isAndroid && useAndroidEmulator) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue