e20b1905cb
- Move FormzInput validators to core/form_inputs/form_inputs.dart - Fix login_screen.dart syntax error (missing 'class' keyword) - Remove unused _isLoading field - Fix unnecessary const keywords - Update login_cubit and register_cubit imports - Remove duplicate FormzInput definitions from register_cubit - Add Toast and Banner UI feedback system - Remove legacy login/register screens (login_code, login_email, login_password, register_step2) - Remove unused warning_banner widget - Update tests for new error messages and DI setup
56 lines
1.5 KiB
Dart
56 lines
1.5 KiB
Dart
import 'package:social_app/core/api/api_client.dart';
|
|
import 'models/signup_request.dart';
|
|
import 'models/login_request.dart';
|
|
import 'models/auth_response.dart';
|
|
|
|
class AuthApi {
|
|
final ApiClient _client;
|
|
static const _prefix = '/api/v1/auth';
|
|
|
|
AuthApi(this._client);
|
|
|
|
Future<SignupStartResponse> signupStart(SignupStartRequest request) async {
|
|
final response = await _client.post(
|
|
'$_prefix/signup/start',
|
|
data: request.toJson(),
|
|
);
|
|
return SignupStartResponse.fromJson(response.data);
|
|
}
|
|
|
|
Future<AuthResponse> signupVerify(SignupVerifyRequest request) async {
|
|
final response = await _client.post(
|
|
'$_prefix/signup/verify',
|
|
data: request.toJson(),
|
|
);
|
|
return AuthResponse.fromJson(response.data);
|
|
}
|
|
|
|
Future<SignupStartResponse> signupResend(SignupResendRequest request) async {
|
|
final response = await _client.post(
|
|
'$_prefix/signup/resend',
|
|
data: request.toJson(),
|
|
);
|
|
return SignupStartResponse.fromJson(response.data);
|
|
}
|
|
|
|
Future<AuthResponse> login(LoginRequest request) async {
|
|
final response = await _client.post(
|
|
'$_prefix/login',
|
|
data: request.toJson(),
|
|
);
|
|
return AuthResponse.fromJson(response.data);
|
|
}
|
|
|
|
Future<AuthResponse> refresh(RefreshRequest request) async {
|
|
final response = await _client.post(
|
|
'$_prefix/refresh',
|
|
data: request.toJson(),
|
|
);
|
|
return AuthResponse.fromJson(response.data);
|
|
}
|
|
|
|
Future<void> logout(LogoutRequest request) async {
|
|
await _client.post('$_prefix/logout', data: request.toJson());
|
|
}
|
|
}
|