Make auth obligatory
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
|
||||
import 'package:grpc/grpc_web.dart';
|
||||
import 'package:softplayer_dart_proto/accounts/accounts_v1.pbgrpc.dart';
|
||||
import 'package:softplayer_dart_proto/main.dart';
|
||||
@ -11,6 +10,7 @@ class AccountLocalData {
|
||||
String uuid;
|
||||
String token;
|
||||
}
|
||||
|
||||
class AccountsGrpc {
|
||||
final GrpcWebClientChannel channel;
|
||||
late AccountsClient accountsStub;
|
||||
@ -22,7 +22,8 @@ class AccountsGrpc {
|
||||
accountsStub = AccountsClient(channel);
|
||||
}
|
||||
|
||||
Future<AccountLocalData> 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,
|
||||
@ -39,7 +40,8 @@ class AccountsGrpc {
|
||||
}
|
||||
}
|
||||
|
||||
Future<AccountLocalData> 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,
|
||||
|
41
lib/api/grpc/environments.dart
Normal file
41
lib/api/grpc/environments.dart
Normal file
@ -0,0 +1,41 @@
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:grpc/grpc_web.dart';
|
||||
import 'package:softplayer_dart_proto/main.dart';
|
||||
|
||||
class EnvironmentLocalData {
|
||||
EnvironmentLocalData({
|
||||
required this.uuid,
|
||||
required this.token,
|
||||
});
|
||||
String uuid;
|
||||
String token;
|
||||
}
|
||||
|
||||
class EnvironmentsGrpc {
|
||||
final GrpcWebClientChannel channel;
|
||||
late EnvironmentsClient envStub;
|
||||
EnvironmentsGrpc({
|
||||
required this.channel,
|
||||
});
|
||||
|
||||
void init() {
|
||||
envStub = EnvironmentsClient(channel);
|
||||
}
|
||||
|
||||
Stream<List<String>> list() async* {
|
||||
List<String> envs = [];
|
||||
try {
|
||||
await for (var feature in envStub.list(Empty(),
|
||||
options: CallOptions(metadata: {
|
||||
"uuid": window.localStorage["uuid"]!,
|
||||
"token": window.localStorage["token"]!,
|
||||
}))) {
|
||||
envs.add(feature.data.name);
|
||||
}
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
yield envs;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user