Replace local user id with person id in JWT payload

This commit is contained in:
shilangyu 2021-04-06 10:39:43 +02:00
parent 6e7957f193
commit 9f2de50b1d
3 changed files with 6 additions and 4 deletions

View File

@ -11,7 +11,7 @@ part 'accounts_store.g.dart';
/// Store that manages all accounts
@JsonSerializable()
class AccountsStore extends ChangeNotifier {
static const prefsKey = 'v2:AccountsStore';
static const prefsKey = 'v3:AccountsStore';
static final _prefs = SharedPreferences.getInstance();
/// Map containing JWT tokens of specific users.
@ -206,7 +206,9 @@ class AccountsStore extends ChangeNotifier {
final userData =
await lemmy.run(GetSite(auth: token.raw)).then((value) => value.myUser);
tokens[instanceHost][userData.person.name] = token;
tokens[instanceHost][userData.person.name] = token.copyWith(
payload: token.payload.copyWith(sub: userData.person.id),
);
await _assignDefaultAccounts();
notifyListeners();

View File

@ -412,7 +412,7 @@ packages:
name: lemmy_api_client
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.0"
version: "0.14.0"
logging:
dependency: transitive
description:

View File

@ -44,7 +44,7 @@ dependencies:
# utils
timeago: ^2.0.27
fuzzy: <1.0.0
lemmy_api_client: ^0.13.0
lemmy_api_client: ^0.14.0
intl: ^0.17.0
matrix4_transform: ^1.1.7
json_annotation: ^4.0.1