Stream Chatty added as example (#21)

* app updated

* readme updated

* rename base folder

* update chatty's readme

Co-authored-by: Neevash Ramdial <[email protected]>
This commit is contained in:
Diego Velásquez López
2021-03-10 14:53:20 -04:00
committed by GitHub
co-authored by Neevash Ramdial
parent c86652dcfc
commit bd6bb66279
111 changed files with 3806 additions and 0 deletions
@@ -0,0 +1,30 @@
import 'package:stream_chatter/data/auth_repository.dart';
import 'package:stream_chatter/data/stream_api_repository.dart';
import 'package:stream_chatter/domain/exceptions/auth_exception.dart';
import 'package:stream_chatter/domain/models/auth_user.dart';
class LoginUseCase {
LoginUseCase(this.authRepository, this.streamApiRepository);
final AuthRepository authRepository;
final StreamApiRepository streamApiRepository;
Future<bool> validateLogin() async {
print('validateLogin');
final user = await authRepository.getAuthUser();
print('user: ${user?.id}');
if (user != null) {
final result = await streamApiRepository.connectIfExist(user.id);
if (result) {
return true;
} else {
throw AuthException(AuthErrorCode.not_chat_user);
}
}
throw AuthException(AuthErrorCode.not_auth);
}
Future<AuthUser> signIn() async {
return await authRepository.signIn();
}
}