Get token
This commit is contained in:
@ -3,6 +3,14 @@ import 'package:grpc/grpc_web.dart';
|
||||
import 'package:softplayer_dart_proto/accounts/accounts_v1.pbgrpc.dart';
|
||||
import 'package:softplayer_dart_proto/main.dart';
|
||||
|
||||
class AccountLocalData {
|
||||
AccountLocalData({
|
||||
required this.uuid,
|
||||
required this.token,
|
||||
});
|
||||
String uuid;
|
||||
String token;
|
||||
}
|
||||
class AccountsGrpc {
|
||||
final GrpcWebClientChannel channel;
|
||||
late AccountsClient accountsStub;
|
||||
@ -14,7 +22,7 @@ class AccountsGrpc {
|
||||
accountsStub = AccountsClient(channel);
|
||||
}
|
||||
|
||||
Future<String> signIn(String username, String email, String password) async {
|
||||
Future<AccountLocalData> signIn(String username, String email, String password) async {
|
||||
final request = AccountWithPassword(
|
||||
data: AccountData(
|
||||
name: username,
|
||||
@ -25,14 +33,13 @@ class AccountsGrpc {
|
||||
));
|
||||
try {
|
||||
final response = await accountsStub.signIn(request);
|
||||
print("$response");
|
||||
return "1";
|
||||
return AccountLocalData(uuid: response.id.id, token: response.token);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> signUp(String username, String email, String password) async {
|
||||
Future<AccountLocalData> signUp(String username, String email, String password) async {
|
||||
final request = AccountWithPassword(
|
||||
data: AccountData(
|
||||
name: username,
|
||||
@ -43,8 +50,7 @@ class AccountsGrpc {
|
||||
));
|
||||
try {
|
||||
final response = await accountsStub.signUp(request);
|
||||
print("$response");
|
||||
return "1";
|
||||
return AccountLocalData(uuid: response.id.id, token: response.token);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
|
Reference in New Issue
Block a user