changeExpiredPassword method

Future<void> changeExpiredPassword(
  1. String username,
  2. String newPassword
)

Changes the user's expired NTUT Portal password.

This must be called when the password has expired (e.g. login failed with LoginFailure.passwordExpired). It uses the established session to change the password, writes the new password to secure storage, and performs a full login to establish a valid session.

Implementation

Future<void> changeExpiredPassword(
  String username,
  String newPassword,
) async {
  if (username.trim().isEmpty) {
    throw ArgumentError.value(username, 'username', 'Username is required');
  }

  await _portalService.changePassword(
    newPassword: newPassword,
    isExpired: true,
  );

  // Perform a full login with the new password to establish a valid session
  await login(username, newPassword);
}