auth_service.dart 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
  2. import 'package:appflowy_backend/protobuf/flowy-user/auth.pb.dart';
  3. import 'package:appflowy_backend/protobuf/flowy-user/user_profile.pbserver.dart';
  4. import 'package:dartz/dartz.dart';
  5. class AuthServiceMapKeys {
  6. const AuthServiceMapKeys._();
  7. // for supabase auth use only.
  8. static const String uuid = 'uuid';
  9. }
  10. abstract class AuthService {
  11. /// Returns [UserProfilePB] if the user is authenticated, otherwise returns [FlowyError].
  12. Future<Either<FlowyError, UserProfilePB>> signIn({
  13. required String email,
  14. required String password,
  15. AuthTypePB authType,
  16. Map<String, String> map,
  17. });
  18. /// Returns [UserProfilePB] if the user is authenticated, otherwise returns [FlowyError].
  19. Future<Either<FlowyError, UserProfilePB>> signUp({
  20. required String name,
  21. required String email,
  22. required String password,
  23. AuthTypePB authType,
  24. Map<String, String> map,
  25. });
  26. ///
  27. Future<Either<FlowyError, UserProfilePB>> signUpWithOAuth({
  28. required String platform,
  29. AuthTypePB authType,
  30. Map<String, String> map,
  31. });
  32. /// Returns a default [UserProfilePB]
  33. Future<Either<FlowyError, UserProfilePB>> signUpAsGuest({
  34. AuthTypePB authType,
  35. Map<String, String> map,
  36. });
  37. ///
  38. Future<void> signOut({
  39. AuthTypePB authType,
  40. });
  41. /// Returns [UserProfilePB] if the user has sign in, otherwise returns null.
  42. Future<Either<FlowyError, UserProfilePB>> getUser();
  43. }