checkUserLoginValidity method
- UserPreferences preferences
Check if the user is still logged in and the credentials are still valid If not, the user is logged out
Implementation
Future<void> checkUserLoginValidity(UserPreferences preferences) async {
if (!ProductQuery.isLoggedIn()) {
return;
}
final User user = ProductQuery.getWriteUser();
final LoginResult loginResult = await LoginResult.getLoginResult(
User(userId: user.userId, password: user.password),
preferences,
);
if (loginResult.type == LoginResultType.unsuccessful) {
// TODO(m123): Notify the user
await logout();
return;
}
/// Save the cookie if necessary
if (user.cookie == null && loginResult.user?.cookie != null) {
putUser(loginResult.user!);
}
}