I use sentry in our flutter app and bugsnag in api backend in laravel. In laravel I am not getting any error.
I am getting some suspicious error in flutter app.
In Sentry I am getting this error
FormatException
FormatException: Unexpected character (at character 1)
<html><head><script type="text/javascript">location.replace("https://malwar...
^
This error shows it happens when _checkIfLoggedIn
code is called.
I am adding the code that I have in there.
void _checkIfLoggedIn() async {
// check if token is set or not...
SharedPreferences localStorage = await SharedPreferences.getInstance();
var token = localStorage.getString('token');
// get the version check
var res = await CallApi().getData('check-new-version');
var body = json.decode(res.body);
if (body['isNewVersionAvailble']) {
msg = body['msg'];
isNewVersionAvailble = true;
}
if (body['isOffline']) {
msg = body['msg'];
isOffline = true;
}
if (token == null) {
// user is not logged in....
setState(() {
isLoading = false;
});
}else{
setState(() {
isLoading = false;
_isLoggedin = body['isLoggedIn'];
});
}
}
In laravel method, there some checks, and a login checks using jwt auth. That’s all in laravel.
Here is the laravel code I have
public function checkNewVersion(Request $reqest)
{
if ($this->isOffline) {
return response()->json([
'msg' => 'We are updating the app. It may take a few hours!',
'isNewVersionAvailble' => false,
'isOffline' => $this->isOffline,
'isLoggedIn' => true,
]);
}
if ($reqest->v != $this->apiVersion) {
return response()->json([
'msg' => 'You are using an older version of the app. Please update your app.',
'isNewVersionAvailble' => true,
'isOffline' => false,
'isLoggedIn' => true,
]);
}
// here check if logged in or not....
try {
if (!$user = JWTAuth::parseToken()->authenticate()) {
return response()->json([
'msg' => 'Your session has expired. Please login again.',
'isNewVersionAvailble' => false,
'isLoggedIn' => false,
'isOffline' => false,
]);
}
} catch (\Throwable $th) {
return response()->json([
'msg' => 'Your session has expired. Please login again.',
'isNewVersionAvailble' => false,
'i
Looking for some experts opinion…
Thank you so much