第二次提交
This commit is contained in:
14
lib/features/auth/domain/errors/auth_failure.dart
Normal file
14
lib/features/auth/domain/errors/auth_failure.dart
Normal file
@@ -0,0 +1,14 @@
|
||||
import 'package:maibu_satabot_v2/core/error/failure.dart';
|
||||
|
||||
class AuthFailure extends Failure implements Exception {
|
||||
final int? code;
|
||||
AuthFailure(super.message, {this.code});
|
||||
}
|
||||
|
||||
class InvalidCredentialsFailure extends AuthFailure {
|
||||
InvalidCredentialsFailure(String message) : super(message);
|
||||
}
|
||||
|
||||
class ServerFailure extends AuthFailure {
|
||||
ServerFailure(String message, int code) : super(message, code: code);
|
||||
}
|
||||
@@ -1,5 +1,12 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
|
||||
import '../../../../core/domain/entities/user_entity.dart';
|
||||
import '../errors/auth_failure.dart';
|
||||
|
||||
abstract class AuthRepository {
|
||||
Future<UserEntity> login(String username, String password, int sourceType);
|
||||
Future<Either<AuthFailure, UserEntity>> login(
|
||||
String username,
|
||||
String password,
|
||||
int sourceType,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
|
||||
import '../../../../core/domain/entities/user_entity.dart';
|
||||
import '../../../../core/domain/usecases/base_usecase.dart';
|
||||
import '../errors/auth_failure.dart';
|
||||
import '../repositories/auth_repository.dart';
|
||||
|
||||
class LoginUseCase implements BaseUseCase<UserEntity, LoginParams> {
|
||||
@@ -8,8 +11,8 @@ class LoginUseCase implements BaseUseCase<UserEntity, LoginParams> {
|
||||
LoginUseCase(this.repository);
|
||||
|
||||
@override
|
||||
Future<UserEntity> call(LoginParams params) {
|
||||
return repository.login(
|
||||
Future<Either<AuthFailure, UserEntity>> call(LoginParams params) async {
|
||||
return await repository.login(
|
||||
params.username,
|
||||
params.password,
|
||||
params.sourceType,
|
||||
|
||||
Reference in New Issue
Block a user