Skip to content

Commit

Permalink
Fix expired reauthorizations (#979)
Browse files Browse the repository at this point in the history
* add migrate method to AccountRecordsDaoInterface

* implement migrate method in AccountRecordsDao

* call migrate when reissuing an authtoken

* change method name
  • Loading branch information
Funkatronics authored Oct 4, 2024
1 parent c10eb19 commit 3ddc933
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.ArrayList;
import java.util.List;

public class AccountRecordsDao extends DbContentProvider<AccountRecord>
implements AccountRecordsDaoInterface, AccountRecordsSchema {

Expand Down Expand Up @@ -43,6 +40,18 @@ public long insert(@NonNull long parentId,
return super.insert(TABLE_ACCOUNTS, accountContentValues);
}

@Override
public long updateParentId(long oldParentId, long newParentId) {
final ContentValues accountContentValues = new ContentValues(1);
accountContentValues.put(COLUMN_ACCOUNTS_PARENT_ID, newParentId);
return super.update(
TABLE_ACCOUNTS,
accountContentValues,
COLUMN_ACCOUNTS_PARENT_ID + "=?",
new String[] { String.valueOf(oldParentId) }
);
}

@Nullable
@Override
public AccountRecord query(@NonNull byte[] publicKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ long insert(@NonNull long parentId, @NonNull byte[] publicKey,
@Nullable String accountLabel, @Nullable Uri accountIcon,
@Nullable String[] chains, @Nullable String[] features);

@IntRange(from = 0)
long updateParentId(long oldParentId, long newParentId);

// @Nullable
// List<AccountRecord> query(int parentId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ public synchronized AuthRecord reissue(@NonNull AuthRecord authRecord) {
} else {
final int id = (int) mAuthorizationsDao.insert(authRecord.identity.getId(), now,
authRecord.chain, authRecord.walletUriBaseId, authRecord.scope);
mAccountsDao.updateParentId(authRecord.id, id);
reissued = new AuthRecord(id, authRecord.identity, authRecord.accounts,
authRecord.chain, authRecord.scope, authRecord.walletUriBase,
authRecord.walletUriBaseId, now,
Expand Down

0 comments on commit 3ddc933

Please sign in to comment.