AuthRepository class
Manages user authentication and profile data.
final auth = ref.watch(authRepositoryProvider);
// Login
final user = await auth.login('111360109', 'password');
// Get user profile (with automatic cache refresh)
final user = await auth.getUser();
// Force refresh (for pull-to-refresh)
final user = await auth.getUser(refresh: true);
Constructors
- AuthRepository({required PortalService portalService, required StudentQueryService studentQueryService, required AppDatabase database, required FlutterSecureStorage secureStorage, required void onAuthStatusChanged(AuthStatus)})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
changePassword(
String currentPassword, String newPassword) → Future< void> - Changes the user's NTUT Portal password.
-
getActiveRegistration(
) → Future< UserRegistration?> - Gets the user's active registration (where enrollment status is "在學").
-
getAvatar(
) → Future< File?> - Gets the current user's avatar image, with local caching.
-
getUser(
{bool refresh = false}) → Future< User?> - Gets the current user with automatic cache refresh.
-
login(
String username, String password) → Future< User> - Authenticates with NTUT Portal and saves the user profile.
-
logout(
) → Future< void> - Logs out and clears all local user data and stored credentials.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
uploadAvatar(
Uint8List imageBytes) → Future< void> - Uploads a new avatar image, replacing the current one.
-
withAuth<
T> (Future< T> call()) → Future<T> -
Executes
callwith automatic re-authentication on session expiry.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- maxAvatarSize → const int
- Maximum avatar file size (20 MB), matching NTUT's client-defined limit.