2021-07-13 05:14:49 +00:00
|
|
|
import 'package:dartz/dartz.dart';
|
|
|
|
import 'package:flowy_sdk/dispatch/dispatch.dart';
|
2021-07-13 06:28:01 +00:00
|
|
|
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
|
2021-07-13 05:14:49 +00:00
|
|
|
|
|
|
|
class AuthRepository {
|
|
|
|
Future<Either<UserDetail, UserError>> signIn(
|
|
|
|
{required String? email, required String? password}) {
|
|
|
|
//
|
|
|
|
final request = SignInRequest.create()
|
|
|
|
..email = email ?? ''
|
|
|
|
..password = password ?? '';
|
|
|
|
|
|
|
|
return UserEventSignIn(request).send();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<Either<UserDetail, UserError>> signUp(
|
|
|
|
{required String? name,
|
|
|
|
required String? password,
|
|
|
|
required String? email}) {
|
|
|
|
final request = SignUpRequest.create()
|
|
|
|
..email = email ?? ''
|
|
|
|
..name = name ?? ''
|
|
|
|
..password = password ?? '';
|
|
|
|
|
|
|
|
return UserEventSignUp(request).send();
|
|
|
|
}
|
2021-07-13 05:23:03 +00:00
|
|
|
|
|
|
|
Future<Either<Unit, UserError>> signOut() {
|
|
|
|
return UserEventSignOut().send();
|
|
|
|
}
|
2021-07-13 05:14:49 +00:00
|
|
|
}
|