Skip to content

Commit

Permalink
fix(user): save one database call in user refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
sg-gs committed Jun 26, 2024
1 parent 958ca63 commit f9be300
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/app/routes/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,18 @@ export default (router: Router, service: any, App: any): Router => {
const { publicKey, privateKey, revocateKey } = req.body;
const userData: any = (req as AuthorizedUser).user;

const keyExists = await service.KeyServer.keysExists(userData);
let [keys, userBucket] = await Promise.all([

Check failure on line 59 in src/app/routes/routes.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

'userBucket' is never reassigned. Use 'const' instead
service.KeyServer.getKeys(userData),
service.User.GetUserBucket(userData),
]);

const keyExists = !!keys;

if (!keyExists && publicKey) {
await service.KeyServer.addKeysLogin(userData, publicKey, privateKey, revocateKey);
keys = await service.KeyServer.getKeys(userData);
}

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

const token = Sign(userData.email, App.config.get('secrets').JWT, true);

const user = {
Expand Down

0 comments on commit f9be300

Please sign in to comment.