You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.4 KiB

2 years ago
  1. // import 'package:flutter_riverpod/flutter_riverpod.dart';
  2. // import 'package:my_flutter_puzzle/application/states/anonymous_auth_state.dart';
  3. // import 'package:my_flutter_puzzle/models/user_info.dart';
  4. // import 'package:my_flutter_puzzle/utils/authentication_client.dart';
  5. // import 'package:my_flutter_puzzle/utils/database_client.dart';
  6. // class AnonymousAuthNotifier extends StateNotifier<AnonymousAuthState> {
  7. // final AuthenticationClient _authentication;
  8. // final DatabaseClient _databaseClient;
  9. // AnonymousAuthNotifier(this._authentication, this._databaseClient)
  10. // : super(const AnonymousAuthState());
  11. // triggerAnonymousLogin({required String name}) async {
  12. // state = const AnonymousAuthState.processing();
  13. // try {
  14. // final user = await _authentication.signInAnonymously(name: name);
  15. // state = AnonymousAuthState.done(user);
  16. // state = const AnonymousAuthState.storingInfo();
  17. // final userData = UserData(
  18. // uid: user.uid,
  19. // name: user.displayName!,
  20. // username: '${user.displayName!.split(' ')[0].toLowerCase()}@${user.uid}',
  21. // timestamp: DateTime.now().millisecondsSinceEpoch,
  22. // );
  23. // await _databaseClient.addUser(userInfo: userData);
  24. // state = AnonymousAuthState.storageDone(userData);
  25. // } catch (e) {
  26. // state = AnonymousAuthState.error(message: e.toString());
  27. // }
  28. // }
  29. // }