Skip to content

Commit

Permalink
fix(auth): remove redundant queries from user refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
sg-gs committed Jan 17, 2024
1 parent b49cbe2 commit 37835ce
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/app/routes/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,18 @@ export default (router: Router, service: any, App: any): Router => {
await service.KeyServer.addKeysLogin(userData, publicKey, privateKey, revocateKey);
}

const keys = await service.KeyServer.getKeys(userData);
const userBucket = await service.User.GetUserBucket(userData);
const [keys, userBucket] = await Promise.all([
service.KeyServer.getKeys(userData),
service.User.GetUserBucket(userData),
]);

const internxtClient = req.headers['internxt-client'];
const token = Sign(
userData.email,
App.config.get('secrets').JWT,
internxtClient === 'x-cloud-web' || internxtClient === 'drive-web',
internxtClient === 'drive-web',
);

const hasTeams = !!(await service.Team.getTeamByMember(userData.email));
const appSumoDetails = await service.AppSumo.GetDetails(userData.id).catch(() => null);

const user = {
email: userData.email,
userId: userData.userId,
Expand All @@ -92,11 +91,11 @@ export default (router: Router, service: any, App: any): Router => {
revocateKey: keys ? keys.revocation_key : null,
bucket: userBucket,
registerCompleted: userData.registerCompleted,
teams: hasTeams,
teams: false,
username: userData.username,
bridgeUser: userData.bridgeUser,
sharedWorkspace: userData.sharedWorkspace,
appSumoDetails: appSumoDetails || null,
appSumoDetails: null,
hasReferralsProgram: await service.UsersReferrals.hasReferralsProgram(
userData.id,
userData.email,
Expand Down

0 comments on commit 37835ce

Please sign in to comment.