fix logOut failing, add invoking logOut before id server change
This commit is contained in:
parent
9d2364b307
commit
3e8c1c46b6
@ -932,6 +932,10 @@ class _NetworkState extends State<_Network> with AutomaticKeepAliveClientMixin {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
final old = await bind.mainGetOption(key: 'custom-rendezvous-server');
|
||||||
|
if (old.isNotEmpty && old != idServer) {
|
||||||
|
await gFFI.userModel.logOut();
|
||||||
|
}
|
||||||
// should set one by one
|
// should set one by one
|
||||||
await bind.mainSetOption(
|
await bind.mainSetOption(
|
||||||
key: 'custom-rendezvous-server', value: idServer);
|
key: 'custom-rendezvous-server', value: idServer);
|
||||||
|
@ -261,6 +261,9 @@ void showServerSettingsWithValue(String id, String relay, String key,
|
|||||||
});
|
});
|
||||||
if (await validate()) {
|
if (await validate()) {
|
||||||
if (id != id0) {
|
if (id != id0) {
|
||||||
|
if (id0.isNotEmpty) {
|
||||||
|
await gFFI.userModel.logOut();
|
||||||
|
}
|
||||||
bind.mainSetOption(key: "custom-rendezvous-server", value: id);
|
bind.mainSetOption(key: "custom-rendezvous-server", value: id);
|
||||||
}
|
}
|
||||||
if (relay != relay0) {
|
if (relay != relay0) {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter_hbb/common/hbbs/hbbs.dart';
|
|
||||||
import 'package:flutter_hbb/common/widgets/peer_tab_page.dart';
|
import 'package:flutter_hbb/common/widgets/peer_tab_page.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
@ -78,15 +77,18 @@ class UserModel {
|
|||||||
|
|
||||||
Future<void> logOut() async {
|
Future<void> logOut() async {
|
||||||
final tag = gFFI.dialogManager.showLoading(translate('Waiting'));
|
final tag = gFFI.dialogManager.showLoading(translate('Waiting'));
|
||||||
final url = await bind.mainGetApiServer();
|
try {
|
||||||
final _ = await http.post(Uri.parse('$url/api/logout'),
|
final url = await bind.mainGetApiServer();
|
||||||
body: {
|
final _ = await http.post(Uri.parse('$url/api/logout'),
|
||||||
'id': await bind.mainGetMyId(),
|
body: {
|
||||||
'uuid': await bind.mainGetUuid(),
|
'id': await bind.mainGetMyId(),
|
||||||
},
|
'uuid': await bind.mainGetUuid(),
|
||||||
headers: await getHttpHeaders());
|
},
|
||||||
await reset();
|
headers: await getHttpHeaders());
|
||||||
gFFI.dialogManager.dismissByTag(tag);
|
} finally {
|
||||||
|
await reset();
|
||||||
|
gFFI.dialogManager.dismissByTag(tag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> login(String userName, String pass) async {
|
Future<Map<String, dynamic>> login(String userName, String pass) async {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user