120 lines
3.1 KiB
Dart
120 lines
3.1 KiB
Dart
part of 'auth_bloc.dart';
|
|
|
|
/// Base class for authentication events handled by [AuthBloc].
|
|
abstract class AuthEvent extends Equatable {
|
|
const AuthEvent();
|
|
@override
|
|
List<Object?> get props => [];
|
|
}
|
|
|
|
/// Triggers a session restore check on app start or after token refresh.
|
|
class AuthCheckRequested extends AuthEvent {
|
|
const AuthCheckRequested();
|
|
}
|
|
|
|
/// Requests sign-in with credentials and optional two-factor / captcha tokens.
|
|
class AuthLoginRequested extends AuthEvent {
|
|
const AuthLoginRequested({
|
|
required this.email,
|
|
required this.password,
|
|
this.totpCode,
|
|
this.captchaToken,
|
|
});
|
|
final String email;
|
|
final String password;
|
|
final String? totpCode;
|
|
final String? captchaToken;
|
|
|
|
@override
|
|
List<Object?> get props => [email, password, totpCode, captchaToken];
|
|
}
|
|
|
|
/// Requests creation of a new user account (web-parity profile fields).
|
|
class AuthRegisterRequested extends AuthEvent {
|
|
const AuthRegisterRequested({
|
|
required this.fullName,
|
|
required this.email,
|
|
required this.password,
|
|
required this.countryOfResidence,
|
|
required this.gender,
|
|
this.phone,
|
|
this.nationality,
|
|
this.referralCode,
|
|
});
|
|
|
|
final String fullName;
|
|
final String email;
|
|
final String password;
|
|
final String countryOfResidence;
|
|
final String gender;
|
|
final String? phone;
|
|
final String? nationality;
|
|
final String? referralCode;
|
|
|
|
@override
|
|
List<Object?> get props => [
|
|
fullName,
|
|
email,
|
|
password,
|
|
countryOfResidence,
|
|
gender,
|
|
phone,
|
|
nationality,
|
|
referralCode,
|
|
];
|
|
}
|
|
|
|
/// Resends the email verification message for [email].
|
|
class AuthResendVerificationRequested extends AuthEvent {
|
|
const AuthResendVerificationRequested(this.email);
|
|
final String email;
|
|
|
|
@override
|
|
List<Object?> get props => [email];
|
|
}
|
|
|
|
/// Clears transient error/success feedback after the UI has shown it.
|
|
class AuthClearFeedback extends AuthEvent {
|
|
const AuthClearFeedback();
|
|
}
|
|
|
|
/// Clears the current session and local auth tokens.
|
|
class AuthLogoutRequested extends AuthEvent {
|
|
const AuthLogoutRequested();
|
|
}
|
|
|
|
/// Fired by [ApiClient] when access/refresh tokens are invalid or expired.
|
|
class AuthSessionExpired extends AuthEvent {
|
|
const AuthSessionExpired();
|
|
}
|
|
|
|
/// Starts TOTP enrollment by fetching QR setup data from the API.
|
|
/// When 2FA is already enabled, [password] and [totpCode] are required to reset.
|
|
class Auth2FASetupRequested extends AuthEvent {
|
|
const Auth2FASetupRequested({this.password, this.totpCode});
|
|
final String? password;
|
|
final String? totpCode;
|
|
|
|
@override
|
|
List<Object?> get props => [password, totpCode];
|
|
}
|
|
|
|
/// Completes TOTP enrollment by submitting the verification code.
|
|
class Auth2FAEnableRequested extends AuthEvent {
|
|
const Auth2FAEnableRequested({required this.code});
|
|
final String code;
|
|
|
|
@override
|
|
List<Object?> get props => [code];
|
|
}
|
|
|
|
/// Disables TOTP after verifying password and a current code.
|
|
class Auth2FADisableRequested extends AuthEvent {
|
|
const Auth2FADisableRequested({required this.password, required this.code});
|
|
final String password;
|
|
final String code;
|
|
|
|
@override
|
|
List<Object?> get props => [password, code];
|
|
}
|