mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
@@ -14,31 +14,37 @@ class HttpType {
|
||||
static const kAuthResTypeEmailCheck = "email_check";
|
||||
}
|
||||
|
||||
enum UserStatus { kDisabled, kNormal, kUnverified }
|
||||
|
||||
// to-do: The UserPayload does not contain all the fields of the user.
|
||||
// Is all the fields of the user needed?
|
||||
class UserPayload {
|
||||
String id = '';
|
||||
String name = '';
|
||||
String email = '';
|
||||
String note = '';
|
||||
int? status;
|
||||
UserStatus status;
|
||||
bool isAdmin = false;
|
||||
|
||||
UserPayload.fromJson(Map<String, dynamic> json)
|
||||
: id = json['id'] ?? '',
|
||||
name = json['name'] ?? '',
|
||||
: name = json['name'] ?? '',
|
||||
email = json['email'] ?? '',
|
||||
note = json['note'] ?? '',
|
||||
status = json['status'],
|
||||
status = json['status'] == 0
|
||||
? UserStatus.kDisabled
|
||||
: json['status'] == -1
|
||||
? UserStatus.kUnverified
|
||||
: UserStatus.kNormal,
|
||||
isAdmin = json['is_admin'] == true;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> map = {
|
||||
'name': name,
|
||||
'status': status == UserStatus.kDisabled
|
||||
? 0
|
||||
: status == UserStatus.kUnverified
|
||||
? -1
|
||||
: 1,
|
||||
};
|
||||
if (status != null) {
|
||||
map['status'] = status!;
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@@ -117,6 +123,7 @@ class LoginResponse {
|
||||
LoginResponse.fromJson(Map<String, dynamic> json) {
|
||||
access_token = json['access_token'];
|
||||
type = json['type'];
|
||||
print('REMOVE ME ================== $json');
|
||||
user = json['user'] != null ? UserPayload.fromJson(json['user']) : null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user