Skip to content

Commit

Permalink
Create interface for AuthUseCase (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
banghuazhao authored Nov 27, 2024
1 parent aca557a commit 613b063
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions android/version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
versionName=6.2.1
versionCode=2024091518
versionName=6.2.3
versionCode=2024091519
2 changes: 1 addition & 1 deletion lib/app/injection_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void initInjection() {
sl.registerLazySingleton<FunctionToolsUseCase>(() => FunctionToolsUseCase());

sl.registerLazySingleton<AuthUseCase>(
() => AuthUseCase(repository: sl(), tokenProvider: sl()));
() => AuthUseCaseImpl(repository: sl(), tokenProvider: sl()));
sl.registerLazySingleton<UserUseCase>(
() => UserUseCase(repository: sl(), tokenProvider: sl()));

Expand Down

This file was deleted.

18 changes: 16 additions & 2 deletions packages/domain/lib/usecases/auth_usecase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,25 @@ import 'package:infrastructure/token_provider.dart';
import '../entities/user.dart';
import '../repositories_abstract/auth_repository.dart';

class AuthUseCase {
abstract class AuthUseCase {
Future<User> signup(String email, String password, String verificationCode,{String? name});
Future<String> login(String email, String password);
Future<void> logout();
Future<void> forgetPassword(String email);
Future<String> resetPassword(String email, String newPassword, String confirmationCode);
Future<void> sendSignupVerificationCode(String email);
Future<String> updatePassword(String newPassword);
Future<String> syncUser(String? displayName, String email, String? photoUrl);
Future<String> validateAppleToken(String identityToken);
Future<bool> validateGoogleToken(String idToken);
Future<bool> isLoggedIn();
}

class AuthUseCaseImpl implements AuthUseCase {
final AuthRepository repository;
final TokenProvider tokenProvider;

AuthUseCase({required this.repository, required this.tokenProvider});
AuthUseCaseImpl({required this.repository, required this.tokenProvider});

Future<User> signup(String email, String password, String verificationCode,
{String? name}) async {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: swiftcomp
description: A cross-platform composite calculator developed with Flutter, based on SwiftComp, designed for engineers and researchers. Available on iOS, Android, and Web.
publish_to: none

version: 6.2.2+2024091518
version: 6.2.3+2024111519

environment:
sdk: ">=2.15.0 <3.0.0"
Expand Down

0 comments on commit 613b063

Please sign in to comment.