auth_service.dart 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. static const String email = 'email';
  10. }
  11. abstract class AuthService {
  12. /// Returns [UserProfilePB] if the user is authenticated, otherwise returns [FlowyError].
  13. Future<Either<FlowyError, UserProfilePB>> signIn({
  14. required String email,
  15. required String password,
  16. AuthTypePB authType,
  17. Map<String, String> map,
  18. });
  19. /// Returns [UserProfilePB] if the user is authenticated, otherwise returns [FlowyError].
  20. Future<Either<FlowyError, UserProfilePB>> signUp({
  21. required String name,
  22. required String email,
  23. required String password,
  24. AuthTypePB authType,
  25. Map<String, String> map,
  26. });
  27. ///
  28. Future<Either<FlowyError, UserProfilePB>> signUpWithOAuth({
  29. required String platform,
  30. AuthTypePB authType,
  31. Map<String, String> map,
  32. });
  33. /// Returns a default [UserProfilePB]
  34. Future<Either<FlowyError, UserProfilePB>> signUpAsGuest({
  35. AuthTypePB authType,
  36. Map<String, String> map,
  37. });
  38. ///
  39. Future<void> signOut();
  40. /// Returns [UserProfilePB] if the user has sign in, otherwise returns null.
  41. Future<Either<FlowyError, UserProfilePB>> getUser();
  42. }