server/lib/apis/auth.dart
2025-05-27 09:39:48 +03:00

37 lines
997 B
Dart

import 'package:dio/dio.dart';
import 'package:server/constants.dart';
import 'package:server/server.dart';
class Auth {
String lastError = '';
login(String email, String password) async {
try {
final response = api.post(
'/collections/users/auth-with-password',
data: {identity: email, password: password},
);
} on DioException catch (e) {
if (e.type == DioExceptionType.connectionError) {
lastError = 'Internet Connection Error';
} else {
lastError = e.response!.data['message'];
}
}
}
register(String email, String password) async {
try {
final response = api.post(
'/collections/users/auth-with-password',
data: {identity: email, password: password},
);
} on DioException catch (e) {
if (e.type == DioExceptionType.connectionError) {
lastError = 'Internet Connection Error';
} else {
lastError = e.response!.data['message'];
}
}
}
}