42 lines
1.4 KiB
Dart
Raw Normal View History

2021-07-13 13:14:49 +08:00
import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/dispatch/dispatch.dart';
2022-07-04 15:07:11 +08:00
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart' show SignInPayload, SignUpPayload, UserProfile;
2021-12-14 18:04:51 +08:00
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
2021-07-13 13:14:49 +08:00
class AuthService {
2021-12-14 18:04:51 +08:00
Future<Either<UserProfile, FlowyError>> signIn({required String? email, required String? password}) {
2021-07-13 13:14:49 +08:00
//
2022-02-24 21:49:18 +08:00
final request = SignInPayload.create()
2021-07-13 13:14:49 +08:00
..email = email ?? ''
..password = password ?? '';
return UserEventSignIn(request).send();
}
2021-12-14 18:04:51 +08:00
Future<Either<UserProfile, FlowyError>> signUp(
2021-11-08 19:19:02 +08:00
{required String? name, required String? password, required String? email}) {
2022-02-24 21:49:18 +08:00
final request = SignUpPayload.create()
2021-07-13 13:14:49 +08:00
..email = email ?? ''
..name = name ?? ''
..password = password ?? '';
2021-11-08 23:15:29 +08:00
return UserEventSignUp(request).send();
// return UserEventSignUp(request).send().then((result) {
// return result.fold((userProfile) async {
// return await FolderEventCreateDefaultWorkspace().send().then((result) {
2021-11-08 23:15:29 +08:00
// return result.fold((workspaceIdentifier) {
// return left(Tuple2(userProfile, workspaceIdentifier.workspaceId));
// }, (error) {
// throw UnimplementedError;
// });
// });
// }, (error) => right(error));
// });
2021-07-13 13:14:49 +08:00
}
2021-12-14 18:04:51 +08:00
Future<Either<Unit, FlowyError>> signOut() {
return UserEventSignOut().send();
}
2021-07-13 13:14:49 +08:00
}