Files
social-app/apps/lib/features/auth/data/models/login_request.dart
T
qzl 0661016827 feat(auth): transition from email to phone-based OTP authentication
- 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
2026-03-19 18:42:05 +08:00

37 lines
859 B
Dart

class LoginRequest {
final String phone;
final String token;
const LoginRequest({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;
}
class RefreshRequest {
final String refreshToken;
const RefreshRequest({required this.refreshToken});
Map<String, dynamic> toJson() => {'refresh_token': refreshToken};
}
class LogoutRequest {
final String refreshToken;
const LogoutRequest({required this.refreshToken});
Map<String, dynamic> toJson() => {'refresh_token': refreshToken};
}