Nathan.fooo 61fd608200
Feat/view map database (#1885)
* refactor: rename structs

* chore: read database id from view

* chore: fix open database error because of create a database view for database id

* chore: fix tests

* chore: rename datbase id to view id in flutter

* refactor: move grid and board to database view folder

* refactor: rename functions

* refactor: move calender to datbase view folder

* refactor: rename app_flowy to appflowy_flutter

* chore: reanming

* chore: fix freeze gen

* chore: remove todos

* refactor: view process events

* chore: add link database test

* chore: just open view if there is opened database
2023-02-26 16:27:17 +08:00

61 lines
1.9 KiB
Dart

import 'package:dartz/dartz.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/uuid.dart';
import 'package:appflowy_backend/dispatch/dispatch.dart';
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart'
show SignInPayloadPB, SignUpPayloadPB, UserProfilePB;
import '../../generated/locale_keys.g.dart';
class AuthService {
Future<Either<UserProfilePB, FlowyError>> signIn(
{required String? email, required String? password}) {
//
final request = SignInPayloadPB.create()
..email = email ?? ''
..password = password ?? '';
return UserEventSignIn(request).send();
}
Future<Either<UserProfilePB, FlowyError>> signUp(
{required String? name,
required String? password,
required String? email}) {
final request = SignUpPayloadPB.create()
..email = email ?? ''
..name = name ?? ''
..password = password ?? '';
return UserEventSignUp(request).send();
// return UserEventSignUp(request).send().then((result) {
// return result.fold((userProfile) async {
// return await FolderEventCreateDefaultWorkspace().send().then((result) {
// return result.fold((workspaceIdentifier) {
// return left(Tuple2(userProfile, workspaceIdentifier.workspaceId));
// }, (error) {
// throw UnimplementedError;
// });
// });
// }, (error) => right(error));
// });
}
Future<Either<Unit, FlowyError>> signOut() {
return UserEventSignOut().send();
}
Future<Either<UserProfilePB, FlowyError>> autoSignUp() {
const password = "AppFlowy123@";
final uid = uuid();
final userEmail = "$uid@appflowy.io";
return signUp(
name: LocaleKeys.defaultUsername.tr(),
password: password,
email: userEmail,
);
}
}