Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions lib/data/data_sources/token_local_data_source.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:injectable/injectable.dart';
import 'package:on_time_front/domain/entities/token_entity.dart';
import 'package:rxdart/subjects.dart';

abstract class TokenLocalDataSource {
Future<void> storeTokens(TokenEntity token);
Expand All @@ -11,22 +10,12 @@ abstract class TokenLocalDataSource {
Future<TokenEntity> getToken();

Future<void> deleteToken();

Stream<bool> get authenticationStream;
}

@Injectable(as: TokenLocalDataSource)
class TokenLocalDataSourceImpl implements TokenLocalDataSource {
final storage = FlutterSecureStorage();

late final _authenticationStreamController = BehaviorSubject<bool>.seeded(
false,
);

@override
Stream<bool> get authenticationStream =>
_authenticationStreamController.asBroadcastStream();

final accessTokenKey = 'accessToken';
final refreshTokenKey = 'refreshToken';

Expand All @@ -52,12 +41,10 @@ class TokenLocalDataSourceImpl implements TokenLocalDataSource {
Future<void> deleteToken() async {
await storage.delete(key: accessTokenKey);
await storage.delete(key: refreshTokenKey);
//_authenticationStreamController.add(false);
}

@override
Future<void> storeAuthToken(String token) async {
await storage.write(key: accessTokenKey, value: token);
//_authenticationStreamController.add(true);
}
}
8 changes: 1 addition & 7 deletions lib/data/repositories/user_repository_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ class UserRepositoryImpl implements UserRepository {
GoogleSignIn get googleSignIn => _googleSignIn;

UserRepositoryImpl(
this._authenticationRemoteDataSource, this._tokenLocalDataSource) {
_tokenLocalDataSource.authenticationStream.listen((state) {
if (state) {
_userStreamController.add(const UserEntity.empty());
}
});
}
this._authenticationRemoteDataSource, this._tokenLocalDataSource);

@override
Future<UserEntity> getUser() async {
Expand Down
Loading