#first commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../../models/user_model.dart';
|
||||
import '../auth_http_datasource.dart';
|
||||
|
||||
class AuthHttpDataSourceImpl implements AuthHttpDataSource {
|
||||
final Dio dio;
|
||||
|
||||
AuthHttpDataSourceImpl(this.dio);
|
||||
|
||||
@override
|
||||
Future<UserModel> login(String username, String password, sourceType) async {
|
||||
final response = await dio.post(
|
||||
'/auth',
|
||||
data: {
|
||||
'username': username,
|
||||
'password': password,
|
||||
'sourceType': sourceType,
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
print('runtimeType = ${response.data.runtimeType}');
|
||||
return UserModel.fromJson(response.data);
|
||||
} else {
|
||||
throw Exception(response.data['message'] ?? 'Login failed');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user