Skip to content

Commit

Permalink
fix(core): game admin reauth in every cfx.re login
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed Feb 13, 2024
1 parent c879c03 commit 9282477
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 37 deletions.
34 changes: 0 additions & 34 deletions core/components/AdminVault/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,40 +414,6 @@ export default class AdminVault {
}


/**
* Refreshes admin's social login data
* TODO: this should be stored on PersistentCache instead of admins.json
* otherwise it refreshes the admins connected
* @param {string} name
* @param {string} provider
* @param {string} identifier
* @param {object} providerData
*/
async refreshAdminSocialData(name, provider, identifier, providerData) {
if (this.admins == false) throw new Error('Admins not set');

//Find admin index
const username = name.toLowerCase();
const adminIndex = this.admins.findIndex((user) => {
return (username === user.name.toLowerCase());
});
if (adminIndex == -1) throw new Error('Admin not found');

//Refresh admin data
if (!this.admins[adminIndex].providers[provider]) throw new Error('Provider not available for this admin');
this.admins[adminIndex].providers[provider].identifier = identifier;
this.admins[adminIndex].providers[provider].data = providerData;

//Saving admin file
this.refreshOnlineAdmins().catch((e) => { });
try {
return await this.writeAdminsFile();
} catch (error) {
throw new Error(`Failed to save admins.json with error: ${error.message}`);
}
}


/**
* Delete admin and save to the admins file
* @param {string} name
Expand Down
3 changes: 0 additions & 3 deletions core/webroutes/authentication/providerCallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ export default async function AuthProviderCallback(ctx: InitializedCtx) {
} satisfies CfxreSessAuthType;
ctx.sessTools.set({ auth: sessData });

//Save the updated provider identifier & data to the admins file
ctx.txAdmin.adminVault.refreshAdminSocialData(vaultAdmin.name, 'citizenfx', fivemIdentifier, userInfo).catch(() => {});

//If the user has a picture, save it to the cache
if (userInfo.picture) {
ctx.txAdmin.persistentCache.set(`admin:picture:${vaultAdmin.name}`, userInfo.picture);
Expand Down
2 changes: 2 additions & 0 deletions docs/dev_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [x] fix the timer issue that keeps requests in memory for longer than needed
- [x] implement rps/heap watcher
- [x] fix issue where the forced password change on save reloads the page instead of moving to the identifiers tab
- [x] fix(core): game admin reauth in every cfx.re login
- [ ] merge prs
- [ ] feat(menu): add keymapping for tp to waypoint (PR #886)
- [ ] fix(nui/PlayerModel): require OneSync for bring and goto (PR #851)
Expand All @@ -16,6 +17,7 @@ seems like it just refreshes the page
- [ ] can I remove `/nui/resetSession`? I think we don't even use cookies anymore
- add txadmin v8 heap to diagnostics
- add snapshot and gc to advanced actions
- fix disallowed intents message

- follow up recipe maintainers regarding fxmanifest description
- fix(core/playerlistmanager): dont wipe license cache on restart
Expand Down

0 comments on commit 9282477

Please sign in to comment.