Skip to content

Commit

Permalink
chore/add-log-on-unexpected-login-error
Browse files Browse the repository at this point in the history
  • Loading branch information
apsantiso committed Nov 13, 2024
1 parent 3d05c9b commit f4190bc
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions src/app/routes/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,32 @@ export class AuthController {
throw createHttpError(401, 'Wrong login credentials');
}

const encSalt = this.service.Crypt.encryptText(user.hKey.toString());
const required2FA = user.secret_2FA && user.secret_2FA.length > 0;
try {
const encSalt = this.service.Crypt.encryptText(user.hKey.toString());
const required2FA = user.secret_2FA && user.secret_2FA.length > 0;

const hasKeys = await this.service.KeyServer.keysExists(user);
const hasKeys = await this.service.KeyServer.keysExists(user);

// TODO: If user has referrals, then apply. Do not catch everything
if (internxtClient === 'drive-mobile') {
this.service.UsersReferrals.applyUserReferral(user.id, 'install-mobile-app').catch((err: Error) => {
this.logReferralError(user.id, err);
});
}
// TODO: If user has referrals, then apply. Do not catch everything
if (internxtClient === 'drive-mobile') {
this.service.UsersReferrals.applyUserReferral(user.id, 'install-mobile-app').catch((err: Error) => {
this.logReferralError(user.id, err);
});
}

if (internxtClient === 'drive-desktop') {
this.service.UsersReferrals.applyUserReferral(user.id, 'install-desktop-app').catch((err: Error) => {
this.logReferralError(user.id, err);
});
}
if (internxtClient === 'drive-desktop') {
this.service.UsersReferrals.applyUserReferral(user.id, 'install-desktop-app').catch((err: Error) => {
this.logReferralError(user.id, err);
});
}

res.status(200).send({ hasKeys, sKey: encSalt, tfa: required2FA });
return res.status(200).send({ hasKeys, sKey: encSalt, tfa: required2FA });
} catch (err) {
this.logger.error(
`[AUTH/Login] USER: ${user.email} ERROR: ${(err as Error).message}, STACK: ${(err as Error).stack}`,
);
throw err;
}
}

private logReferralError(userId: unknown, err: Error) {
Expand Down

0 comments on commit f4190bc

Please sign in to comment.