Sim Binding Done #1
This commit is contained in:
@@ -8,41 +8,73 @@ class AuthService {
|
|||||||
final Dio _dio;
|
final Dio _dio;
|
||||||
AuthService(this._dio);
|
AuthService(this._dio);
|
||||||
|
|
||||||
Future <void> simVerify(String uuid, String cifNo) async{
|
Future <void> simVerify(String uuid, String cifNo) async{
|
||||||
try{
|
|
||||||
final response = await _dio.post(
|
try{
|
||||||
'/api/sim-details-verify',
|
|
||||||
data: {
|
final response = await _dio.post(
|
||||||
'uuid': uuid,
|
|
||||||
'cifNo': cifNo,
|
'/api/sim-details-verify',
|
||||||
}
|
|
||||||
);
|
data: {
|
||||||
if (response.statusCode == 200) {
|
|
||||||
final String message = response.data.toString().trim().toUpperCase();
|
'uuid': uuid,
|
||||||
|
|
||||||
if (message == "VERIFIED") {
|
'cifNo': cifNo,
|
||||||
return; // Success
|
|
||||||
|
}
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
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 {
|
} 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) {
|
catch (e) {
|
||||||
print(e.toString());
|
|
||||||
|
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 {
|
Future<AuthToken> login(AuthCredentials credentials) async {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class _VerificationScreenState extends State<VerificationScreen> {
|
|||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_statusMessage = " $e SIM verification failed. Please try again.";
|
_statusMessage = e.toString();
|
||||||
_isVerifying = false;
|
_isVerifying = false;
|
||||||
_verificationFailed = true;
|
_verificationFailed = true;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user