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
This commit is contained in:
@@ -4,33 +4,32 @@ import 'package:social_app/features/auth/data/models/login_request.dart';
|
||||
import 'package:social_app/features/auth/data/models/auth_response.dart';
|
||||
|
||||
void main() {
|
||||
group('SignupStartRequest', () {
|
||||
test('serializes to JSON', () {
|
||||
final request = SignupStartRequest(
|
||||
username: 'testuser',
|
||||
email: 'test@example.com',
|
||||
password: 'password123',
|
||||
);
|
||||
group('OtpSendRequest', () {
|
||||
test('serializes e164 phone to JSON', () {
|
||||
final request = OtpSendRequest(phone: '+14155552671');
|
||||
|
||||
final json = request.toJson();
|
||||
|
||||
expect(json['username'], 'testuser');
|
||||
expect(json['email'], 'test@example.com');
|
||||
expect(json['password'], 'password123');
|
||||
expect(json['phone'], '+14155552671');
|
||||
});
|
||||
|
||||
test('normalizes 00 prefix to plus', () {
|
||||
final request = OtpSendRequest(phone: '0014155552671');
|
||||
|
||||
final json = request.toJson();
|
||||
|
||||
expect(json['phone'], '+14155552671');
|
||||
});
|
||||
});
|
||||
|
||||
group('LoginRequest', () {
|
||||
test('serializes to JSON', () {
|
||||
final request = LoginRequest(
|
||||
email: 'test@example.com',
|
||||
password: 'password123',
|
||||
);
|
||||
test('serializes e164 to JSON', () {
|
||||
final request = LoginRequest(phone: '+14155552671', token: '123456');
|
||||
|
||||
final json = request.toJson();
|
||||
|
||||
expect(json['email'], 'test@example.com');
|
||||
expect(json['password'], 'password123');
|
||||
expect(json['phone'], '+14155552671');
|
||||
expect(json['token'], '123456');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -41,7 +40,7 @@ void main() {
|
||||
'refresh_token': 'test_refresh',
|
||||
'expires_in': 3600,
|
||||
'token_type': 'bearer',
|
||||
'user': {'id': '123', 'email': 'test@example.com'},
|
||||
'user': {'id': '123', 'phone': '+8613812345678'},
|
||||
};
|
||||
|
||||
final response = AuthResponse.fromJson(json);
|
||||
@@ -50,7 +49,7 @@ void main() {
|
||||
expect(response.refreshToken, 'test_refresh');
|
||||
expect(response.expiresIn, 3600);
|
||||
expect(response.user.id, '123');
|
||||
expect(response.user.email, 'test@example.com');
|
||||
expect(response.user.phone, '+8613812345678');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user