login added
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import '../../core/network/app_exceptions.dart';
|
||||
import 'package:tm_app/data/services/model/login_response/login_response_model.dart';
|
||||
|
||||
import '../../core/utils/result.dart';
|
||||
import '../models/user_model.dart';
|
||||
import '../services/auth_service.dart';
|
||||
|
||||
class AuthRepository {
|
||||
@@ -9,15 +9,10 @@ class AuthRepository {
|
||||
AuthRepository({required AuthService authService})
|
||||
: _authService = authService;
|
||||
|
||||
Future<Result<UserModel>> login(String email, String password) async {
|
||||
try {
|
||||
final response = await _authService.login(email, password);
|
||||
final user = UserModel(token: response['token'], name: response['name']);
|
||||
return Result.ok(user);
|
||||
} on Exception {
|
||||
return Result.error(
|
||||
AuthenticationException('Email or password is not correct.'),
|
||||
);
|
||||
}
|
||||
Future<Result<LoginResponseModel>> login({
|
||||
required String username,
|
||||
required String password,
|
||||
}) async {
|
||||
return _authService.login(username: username, password: password);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user