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:
qzl
2026-03-19 18:42:05 +08:00
parent 636b37ee5a
commit 0661016827
29 changed files with 615 additions and 2030 deletions
+4 -48
View File
@@ -9,34 +9,13 @@ class AuthApi {
AuthApi(this._client);
Future<VerificationCreateResponse> createVerification(
SignupStartRequest request,
) async {
final response = await _client.post(
'$_prefix/verifications',
data: request.toJson(),
);
return VerificationCreateResponse.fromJson(response.data);
Future<void> sendOtp(OtpSendRequest request) async {
await _client.post('$_prefix/otp/send', data: request.toJson());
}
Future<AuthResponse> verifyVerification(SignupVerifyRequest request) async {
Future<AuthResponse> createPhoneSession(LoginRequest request) async {
final response = await _client.post(
'$_prefix/verify',
data: {'type': 'signup', ...request.toJson()},
);
return AuthResponse.fromJson(response.data);
}
Future<void> resendVerification(SignupResendRequest request) async {
await _client.post(
'$_prefix/resend',
data: {'type': 'signup', ...request.toJson()},
);
}
Future<AuthResponse> createSession(LoginRequest request) async {
final response = await _client.post(
'$_prefix/sessions',
'$_prefix/phone-session',
data: request.toJson(),
);
return AuthResponse.fromJson(response.data);
@@ -53,27 +32,4 @@ class AuthApi {
Future<void> deleteSession(LogoutRequest request) async {
await _client.delete('$_prefix/sessions', data: request.toJson());
}
Future<void> requestPasswordReset(String email) async {
await _client.post(
'$_prefix/resend',
data: {'type': 'recovery', 'email': email},
);
}
Future<void> confirmPasswordReset({
required String email,
required String token,
required String newPassword,
}) async {
await _client.post(
'$_prefix/verify',
data: {
'type': 'recovery',
'email': email,
'token': token,
'new_password': newPassword,
},
);
}
}