mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-12 02:57:22 +00:00
Merge pull request #2978 from Heap-Hop/master
feat: add device info in LoginRequest
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_hbb/models/peer_model.dart';
|
||||
|
||||
import '../../models/platform_model.dart';
|
||||
|
||||
class HttpType {
|
||||
static const kAuthReqTypeAccount = "account";
|
||||
static const kAuthReqTypeMobile = "mobile";
|
||||
@@ -48,6 +52,16 @@ class PeerPayload {
|
||||
}
|
||||
}
|
||||
|
||||
class DeviceInfo {
|
||||
static Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['os'] = Platform.operatingSystem;
|
||||
data['type'] = "client";
|
||||
data['name'] = bind.mainGetHostname();
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class LoginRequest {
|
||||
String? username;
|
||||
String? password;
|
||||
@@ -56,7 +70,7 @@ class LoginRequest {
|
||||
bool? autoLogin;
|
||||
String? type;
|
||||
String? verificationCode;
|
||||
String? deviceInfo;
|
||||
Map<String, dynamic> deviceInfo = DeviceInfo.toJson();
|
||||
|
||||
LoginRequest(
|
||||
{this.username,
|
||||
@@ -65,19 +79,7 @@ class LoginRequest {
|
||||
this.uuid,
|
||||
this.autoLogin,
|
||||
this.type,
|
||||
this.verificationCode,
|
||||
this.deviceInfo});
|
||||
|
||||
LoginRequest.fromJson(Map<String, dynamic> json) {
|
||||
username = json['username'];
|
||||
password = json['password'];
|
||||
id = json['id'];
|
||||
uuid = json['uuid'];
|
||||
autoLogin = json['autoLogin'];
|
||||
type = json['type'];
|
||||
verificationCode = json['verificationCode'];
|
||||
deviceInfo = json['deviceInfo'];
|
||||
}
|
||||
this.verificationCode});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
@@ -88,7 +90,7 @@ class LoginRequest {
|
||||
data['autoLogin'] = autoLogin ?? '';
|
||||
data['type'] = type ?? '';
|
||||
data['verificationCode'] = verificationCode ?? '';
|
||||
data['deviceInfo'] = deviceInfo ?? '';
|
||||
data['deviceInfo'] = deviceInfo;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,13 +80,15 @@ class UserModel {
|
||||
final tag = gFFI.dialogManager.showLoading(translate('Waiting'));
|
||||
try {
|
||||
final url = await bind.mainGetApiServer();
|
||||
final authHeaders = getHttpHeaders();
|
||||
authHeaders['Content-Type'] = "application/json";
|
||||
await http
|
||||
.post(Uri.parse('$url/api/logout'),
|
||||
body: {
|
||||
body: jsonEncode({
|
||||
'id': await bind.mainGetMyId(),
|
||||
'uuid': await bind.mainGetUuid(),
|
||||
},
|
||||
headers: getHttpHeaders())
|
||||
}),
|
||||
headers: authHeaders)
|
||||
.timeout(Duration(seconds: 2));
|
||||
} catch (e) {
|
||||
print("request /api/logout failed: err=$e");
|
||||
|
||||
Reference in New Issue
Block a user