mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-14 16:31:28 +03:00
default shared password (#12868)
Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
@@ -248,15 +248,17 @@ class AbProfile {
|
|||||||
String name;
|
String name;
|
||||||
String owner;
|
String owner;
|
||||||
String? note;
|
String? note;
|
||||||
|
dynamic info;
|
||||||
int rule;
|
int rule;
|
||||||
|
|
||||||
AbProfile(this.guid, this.name, this.owner, this.note, this.rule);
|
AbProfile(this.guid, this.name, this.owner, this.note, this.rule, this.info);
|
||||||
|
|
||||||
AbProfile.fromJson(Map<String, dynamic> json)
|
AbProfile.fromJson(Map<String, dynamic> json)
|
||||||
: guid = json['guid'] ?? '',
|
: guid = json['guid'] ?? '',
|
||||||
name = json['name'] ?? '',
|
name = json['name'] ?? '',
|
||||||
owner = json['owner'] ?? '',
|
owner = json['owner'] ?? '',
|
||||||
note = json['note'] ?? '',
|
note = json['note'] ?? '',
|
||||||
|
info = json['info'],
|
||||||
rule = json['rule'] ?? 0;
|
rule = json['rule'] ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1491,6 +1491,13 @@ void connectInPeerTab(BuildContext context, Peer peer, PeerTabIndex tab,
|
|||||||
password = peer.password;
|
password = peer.password;
|
||||||
isSharedPassword = true;
|
isSharedPassword = true;
|
||||||
}
|
}
|
||||||
|
if (password.isEmpty) {
|
||||||
|
final abPassword = gFFI.abModel.getdefaultSharedPassword();
|
||||||
|
if (abPassword != null) {
|
||||||
|
password = abPassword;
|
||||||
|
isSharedPassword = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
connect(context, peer.id,
|
connect(context, peer.id,
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ class AbModel {
|
|||||||
debugPrint("pull ab list");
|
debugPrint("pull ab list");
|
||||||
List<AbProfile> abProfiles = List.empty(growable: true);
|
List<AbProfile> abProfiles = List.empty(growable: true);
|
||||||
abProfiles.add(AbProfile(_personalAbGuid!, _personalAddressBookName,
|
abProfiles.add(AbProfile(_personalAbGuid!, _personalAddressBookName,
|
||||||
gFFI.userModel.userName.value, null, ShareRule.read.value));
|
gFFI.userModel.userName.value, null, ShareRule.read.value, null));
|
||||||
// get all address book name
|
// get all address book name
|
||||||
await _getSharedAbProfiles(abProfiles);
|
await _getSharedAbProfiles(abProfiles);
|
||||||
addressbooks.removeWhere((key, value) =>
|
addressbooks.removeWhere((key, value) =>
|
||||||
@@ -609,7 +609,7 @@ class AbModel {
|
|||||||
if (name == null || guid == null) {
|
if (name == null || guid == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ab = Ab(AbProfile(guid, name, '', '', ShareRule.read.value),
|
ab = Ab(AbProfile(guid, name, '', '', ShareRule.read.value, null),
|
||||||
name == _personalAddressBookName);
|
name == _personalAddressBookName);
|
||||||
}
|
}
|
||||||
addressbooks[name] = ab;
|
addressbooks[name] = ab;
|
||||||
@@ -767,6 +767,28 @@ class AbModel {
|
|||||||
_peerIdUpdateListeners.remove(key);
|
_peerIdUpdateListeners.remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String? getdefaultSharedPassword() {
|
||||||
|
if (current.isPersonal()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final profile = current.sharedProfile();
|
||||||
|
if (profile == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (profile.info is Map) {
|
||||||
|
final password = (profile.info as Map)['password'];
|
||||||
|
if (password is String && password.isNotEmpty) {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint("getdefaultSharedPassword: $e");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// #endregion
|
// #endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user