refreshLogin method
Re-authenticates with stored credentials to refresh the session and update login-level fields (avatar filename, password expiry) in the DB.
Throws NotLoggedInException if no stored credentials are available. Throws DioException on network failure.
Implementation
Future<UserDto> refreshLogin() async {
final username = await _secureStorage.read(key: _usernameKey);
final password = await _secureStorage.read(key: _passwordKey);
if (username == null || password == null) throw NotLoggedInException();
final userDto = await _portalService.login(username, password);
_onAuthStatusChanged(.authenticated);
await (_database.update(
_database.users,
)..where((u) => u.studentId.equals(username))).write(
UsersCompanion(
avatarFilename: Value(userDto.avatarFilename ?? ''),
passwordExpiresInDays: Value(userDto.passwordExpiresInDays),
),
);
return userDto;
}