mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-08-26 10:16:54 +08:00
store user info after login
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@ -14,6 +14,8 @@ class HttpType {
|
||||
static const kAuthResTypeEmailCheck = "email_check";
|
||||
}
|
||||
|
||||
// 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 = '';
|
||||
@ -29,6 +31,16 @@ class UserPayload {
|
||||
note = json['note'] ?? '',
|
||||
status = json['status'],
|
||||
isAdmin = json['is_admin'] == true;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> map = {
|
||||
'name': name,
|
||||
};
|
||||
if (status != null) {
|
||||
map['status'] = status!;
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
class PeerPayload {
|
||||
|
@ -424,6 +424,8 @@ Future<bool?> loginDialog() async {
|
||||
if (resp.access_token != null) {
|
||||
await bind.mainSetLocalOption(
|
||||
key: 'access_token', value: resp.access_token!);
|
||||
await bind.mainSetLocalOption(
|
||||
key: 'user_info', value: jsonEncode(resp.user ?? {}));
|
||||
close(true);
|
||||
return;
|
||||
}
|
||||
@ -482,12 +484,8 @@ Future<bool?> loginDialog() async {
|
||||
curOP: curOP,
|
||||
cbLogin: (Map<String, dynamic> authBody) {
|
||||
try {
|
||||
final loginResp =
|
||||
gFFI.userModel.getLoginResponseFromAuthBody(authBody);
|
||||
if (loginResp.access_token != null) {
|
||||
bind.mainSetLocalOption(
|
||||
key: 'access_token', value: loginResp.access_token!);
|
||||
}
|
||||
// access_token is already stored in the rust side.
|
||||
gFFI.userModel.getLoginResponseFromAuthBody(authBody);
|
||||
} catch (e) {
|
||||
debugPrint('Failed too parse oidc login body: "$authBody"');
|
||||
}
|
||||
|
Reference in New Issue
Block a user