37 lines
997 B
Dart
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'];
|
|
}
|
|
}
|
|
}
|
|
}
|