Signup and signing are ready
This commit is contained in:
		
							
								
								
									
										52
									
								
								lib/api/grpc/accounts.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								lib/api/grpc/accounts.dart
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,52 @@
 | 
			
		||||
 | 
			
		||||
import 'package:grpc/grpc_web.dart';
 | 
			
		||||
import 'package:softplayer_dart_proto/accounts/accounts_v1.pbgrpc.dart';
 | 
			
		||||
import 'package:softplayer_dart_proto/main.dart';
 | 
			
		||||
 | 
			
		||||
class AccountsGrpc {
 | 
			
		||||
  final GrpcWebClientChannel channel;
 | 
			
		||||
  late AccountsClient accountsStub;
 | 
			
		||||
  AccountsGrpc({
 | 
			
		||||
    required this.channel,
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  void init() {
 | 
			
		||||
    accountsStub = AccountsClient(channel);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Future<String> signIn(String username, String email, String password) async {
 | 
			
		||||
    final request = AccountWithPassword(
 | 
			
		||||
        data: AccountData(
 | 
			
		||||
          name: username,
 | 
			
		||||
          email: email,
 | 
			
		||||
        ),
 | 
			
		||||
        password: AccountPassword(
 | 
			
		||||
          password: password,
 | 
			
		||||
        ));
 | 
			
		||||
    try {
 | 
			
		||||
      final response = await accountsStub.signIn(request);
 | 
			
		||||
      print("$response");
 | 
			
		||||
      return "1";
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
      rethrow;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Future<String> signUp(String username, String email, String password) async {
 | 
			
		||||
    final request = AccountWithPassword(
 | 
			
		||||
        data: AccountData(
 | 
			
		||||
          name: username,
 | 
			
		||||
          email: email,
 | 
			
		||||
        ),
 | 
			
		||||
        password: AccountPassword(
 | 
			
		||||
          password: password,
 | 
			
		||||
        ));
 | 
			
		||||
    try {
 | 
			
		||||
      final response = await accountsStub.signUp(request);
 | 
			
		||||
      print("$response");
 | 
			
		||||
      return "1";
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
      rethrow;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user