2023-05-21 18:53:59 +08:00
|
|
|
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
|
|
|
|
import 'package:appflowy_backend/protobuf/flowy-user/auth.pb.dart';
|
|
|
|
import 'package:appflowy_backend/protobuf/flowy-user/user_profile.pbserver.dart';
|
|
|
|
import 'package:dartz/dartz.dart';
|
|
|
|
|
|
|
|
class AuthServiceMapKeys {
|
|
|
|
const AuthServiceMapKeys._();
|
|
|
|
|
|
|
|
// for supabase auth use only.
|
|
|
|
static const String uuid = 'uuid';
|
2023-07-14 13:37:13 +08:00
|
|
|
static const String email = 'email';
|
2023-05-21 18:53:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
abstract class AuthService {
|
|
|
|
/// Returns [UserProfilePB] if the user is authenticated, otherwise returns [FlowyError].
|
|
|
|
Future<Either<FlowyError, UserProfilePB>> signIn({
|
|
|
|
required String email,
|
|
|
|
required String password,
|
|
|
|
AuthTypePB authType,
|
|
|
|
Map<String, String> map,
|
|
|
|
});
|
|
|
|
|
|
|
|
/// Returns [UserProfilePB] if the user is authenticated, otherwise returns [FlowyError].
|
|
|
|
Future<Either<FlowyError, UserProfilePB>> signUp({
|
|
|
|
required String name,
|
|
|
|
required String email,
|
|
|
|
required String password,
|
|
|
|
AuthTypePB authType,
|
|
|
|
Map<String, String> map,
|
|
|
|
});
|
|
|
|
|
|
|
|
///
|
|
|
|
Future<Either<FlowyError, UserProfilePB>> signUpWithOAuth({
|
|
|
|
required String platform,
|
|
|
|
AuthTypePB authType,
|
|
|
|
Map<String, String> map,
|
|
|
|
});
|
|
|
|
|
|
|
|
/// Returns a default [UserProfilePB]
|
|
|
|
Future<Either<FlowyError, UserProfilePB>> signUpAsGuest({
|
|
|
|
AuthTypePB authType,
|
|
|
|
Map<String, String> map,
|
|
|
|
});
|
|
|
|
|
|
|
|
///
|
2023-07-14 13:37:13 +08:00
|
|
|
Future<void> signOut();
|
2023-05-21 18:53:59 +08:00
|
|
|
|
|
|
|
/// Returns [UserProfilePB] if the user has sign in, otherwise returns null.
|
|
|
|
Future<Either<FlowyError, UserProfilePB>> getUser();
|
|
|
|
}
|