user-auth-service.ts 608 B

1234567891011121314151617181920212223
  1. import { logger } from "#logger";
  2. import bcript from "bcrypt";
  3. import { DayjsUtils } from "#dayjsUtils";
  4. // db
  5. import { db } from "#db";
  6. import { sql } from "slonik";
  7. class userAuthService {
  8. async authTriesIncrement(userId: string) {
  9. await db.any(
  10. sql.unsafe`update users.user_profiles set wrong_pass_tries = wrong_pass_tries + 1 where user_id = ${userId}`,
  11. );
  12. }
  13. async resetAuthTries(userId: string) {
  14. await db.any(
  15. sql.unsafe`update users.user_profiles set wrong_pass_tries = 0 where user_id = ${userId}`,
  16. );
  17. }
  18. }
  19. export const UserAuthService = new userAuthService();