mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
region and access_management ui
This commit is contained in:
@ -45,33 +45,38 @@ class AuthenticationAPI {
|
||||
"regionUuid": regionUuid
|
||||
},
|
||||
showServerMessage: true,
|
||||
options: Options(),
|
||||
expectedResponseModel: (json) {
|
||||
Map<String, dynamic> parsedJson = jsonDecode(json);
|
||||
int cooldown = parsedJson['data']['cooldown'];
|
||||
debugPrint('Cooldown: $cooldown seconds');
|
||||
return cooldown;
|
||||
return 30;
|
||||
}
|
||||
);
|
||||
return response;
|
||||
return 30;
|
||||
} on DioError catch (e) {
|
||||
|
||||
if (e.response != null) {
|
||||
if (e.response!.statusCode == 400) {
|
||||
// Handle 400 Bad Request
|
||||
final errorData = e.response!.data;
|
||||
String errorMessage = errorData['message'] ?? 'Unknown error';
|
||||
int cooldown = errorData['data']['cooldown'] ?? 0;
|
||||
return cooldown;
|
||||
String errorMessage = errorData['message'];
|
||||
debugPrint('Unexpected Error: $errorMessage');
|
||||
if(errorMessage=='User not found'){
|
||||
return 1;
|
||||
}else{
|
||||
int cooldown = errorData['data']['cooldown'] ?? 1;
|
||||
return cooldown;
|
||||
}
|
||||
|
||||
} else {
|
||||
debugPrint('Error: ${e.response!.statusCode} - ${e.response!.statusMessage}');
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
debugPrint('Error: ${e.message}');
|
||||
return 1;
|
||||
}
|
||||
return null;
|
||||
return 1;
|
||||
} catch (e) {
|
||||
debugPrint('Unexpected Error: $e');
|
||||
return null;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,7 +84,7 @@ class AuthenticationAPI {
|
||||
{required String email, required String otpCode}) async {
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.verifyOtp,
|
||||
body: {"email": email, "type": "VERIFICATION", "otpCode": otpCode},
|
||||
body: {"email": email, "type": "PASSWORD", "otpCode": otpCode},
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
if (json['message'] == 'Otp Verified Successfully') {
|
||||
|
Reference in New Issue
Block a user