auth_service.dart 1.6 KB

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