0661016827
- Replace Email+Password login with Phone+OTP flow - Remove RegisterCubit and registration screens (email verification) - Remove ResetPasswordCubit and reset password screens - Add phone normalization and international dial code support - Update LoginCubit with sendCode/resend cooldown logic - Add new widgets: phone prefix selector, confirm sheet - Update all auth API endpoints: /otp/send, /phone-session - Update form inputs: Email -> Phone with E.164 validation - Update tests for new auth flow
29 lines
684 B
Dart
29 lines
684 B
Dart
class OtpSendRequest {
|
|
final String phone;
|
|
|
|
const OtpSendRequest({required this.phone});
|
|
|
|
Map<String, dynamic> toJson() => {'phone': _normalizePhone(phone)};
|
|
}
|
|
|
|
class PhoneSessionRequest {
|
|
final String phone;
|
|
final String token;
|
|
|
|
const PhoneSessionRequest({required this.phone, required this.token});
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'phone': _normalizePhone(phone),
|
|
'token': token,
|
|
};
|
|
}
|
|
|
|
String _normalizePhone(String input) {
|
|
var normalized = input.trim();
|
|
normalized = normalized.replaceAll(RegExp(r'[\s\-\(\)]'), '');
|
|
if (normalized.startsWith('00') && normalized.length > 2) {
|
|
return '+${normalized.substring(2)}';
|
|
}
|
|
return normalized;
|
|
}
|