checkExistWepinLoginSession method
Future<bool>
checkExistWepinLoginSession(
)
inherited
Implementation
Future<bool> checkExistWepinLoginSession() async {
final token = await wepinStorage.getLocalStorage<WepinToken>('wepin:connectUser');
final userId = await wepinStorage.getLocalStorage<String>('user_id');
if (token != null && userId != null) {
wepinNetwork.setAuthToken(token.accessToken, token.refreshToken);
if(_isJwtTokenExpired(token.accessToken)){
try {
final response = await wepinNetwork.getAccessToken(userId);
final newToken = WepinToken(
accessToken: response,
refreshToken: token.refreshToken,
);
await wepinStorage.setLocalStorage('wepin:connectUser', newToken);
wepinNetwork.setAuthToken(newToken.accessToken, newToken.refreshToken);
return true;
} catch (error) {
// print('error - $error');
await clearSession();
return false;
}
}else {
return true;
}
} else {
await clearSession();
return false;
}
}