Sim Binding Done #1
This commit is contained in:
@@ -8,41 +8,73 @@ class AuthService {
|
||||
final Dio _dio;
|
||||
AuthService(this._dio);
|
||||
|
||||
Future <void> simVerify(String uuid, String cifNo) async{
|
||||
try{
|
||||
final response = await _dio.post(
|
||||
'/api/sim-details-verify',
|
||||
data: {
|
||||
'uuid': uuid,
|
||||
'cifNo': cifNo,
|
||||
}
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
final String message = response.data.toString().trim().toUpperCase();
|
||||
|
||||
if (message == "VERIFIED") {
|
||||
return; // Success
|
||||
Future <void> simVerify(String uuid, String cifNo) async{
|
||||
|
||||
try{
|
||||
|
||||
final response = await _dio.post(
|
||||
|
||||
'/api/sim-details-verify',
|
||||
|
||||
data: {
|
||||
|
||||
'uuid': uuid,
|
||||
|
||||
'cifNo': cifNo,
|
||||
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
final String message = response.data.toString().toUpperCase();
|
||||
|
||||
if (message.contains("VERIFIED")) {
|
||||
|
||||
return; // Success
|
||||
|
||||
} else {
|
||||
|
||||
throw AuthException(message); // Throw message received
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
throw AuthException(message); // Throw message received
|
||||
|
||||
throw AuthException('Verification Failed');
|
||||
|
||||
}
|
||||
} else {
|
||||
throw AuthException('Verification Failed');
|
||||
|
||||
} on DioException catch (e) {
|
||||
|
||||
if (kDebugMode) {
|
||||
|
||||
print(e.toString());
|
||||
|
||||
}
|
||||
|
||||
if (e.response?.statusCode == 401) {
|
||||
|
||||
throw AuthException(
|
||||
|
||||
e.response?.data['error'] ?? 'SOMETHING WENT WRONG');
|
||||
|
||||
}
|
||||
|
||||
throw NetworkException('Network error during verification');
|
||||
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
if (kDebugMode) {
|
||||
print(e.toString());
|
||||
|
||||
catch (e) {
|
||||
|
||||
throw UnexpectedException(
|
||||
|
||||
'Unexpected error during verification: ${e.toString()}');
|
||||
|
||||
}
|
||||
if (e.response?.statusCode == 401) {
|
||||
throw AuthException(
|
||||
e.response?.data['error'] ?? 'SOMETHING WENT WRONG');
|
||||
}
|
||||
throw NetworkException('Network error during verification');
|
||||
|
||||
}
|
||||
catch (e) {
|
||||
throw UnexpectedException(
|
||||
'Unexpected error during verification: ${e.toString()}');
|
||||
}
|
||||
}
|
||||
|
||||
Future<AuthToken> login(AuthCredentials credentials) async {
|
||||
try {
|
||||
|
||||
@@ -104,7 +104,7 @@ class _VerificationScreenState extends State<VerificationScreen> {
|
||||
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
_statusMessage = " $e SIM verification failed. Please try again.";
|
||||
_statusMessage = e.toString();
|
||||
_isVerifying = false;
|
||||
_verificationFailed = true;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user