Get token

This commit is contained in:
2024-04-05 17:57:46 +02:00
parent 45a52d5410
commit 350cf9d4c3
4 changed files with 28 additions and 9 deletions

View File

@ -1,3 +1,5 @@
import 'dart:html';
import 'package:flutter/material.dart';
import 'package:grpc/grpc_web.dart';
import 'package:softplayer_web/api/grpc/accounts.dart';
@ -25,7 +27,11 @@ class _SignInFormState extends State<SignInForm> {
final password = passwordCtrl.text;
widget.accountsGrpc
.signIn(username, "", password)
.then((value) => null)
.then((rs) {
window.localStorage["token"] = rs.token;
window.localStorage["uuid"] = rs.uuid;
Navigator.of(context, rootNavigator: true).pop();
})
.catchError((e) {
GrpcError error = e;
String msg;

View File

@ -1,3 +1,5 @@
import 'dart:html';
import 'package:flutter/material.dart';
import 'package:grpc/grpc_web.dart';
import 'package:softplayer_web/api/grpc/accounts.dart';
@ -32,7 +34,12 @@ class _SignUpFormState extends State<SignUpForm> {
final email = emailCtrl.text;
widget.accountsGrpc
.signUp(username, email, password)
.then((value) => null)
.then((rs) {
window.localStorage["token"] = rs.token;
window.localStorage["uuid"] = rs.uuid;
Navigator.of(context, rootNavigator: true).pop();
})
.catchError((e) {
GrpcError error = e;
String msg;