From bc010c94ff1b695164f1a51adb8dcb672d2c8701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=97=D0=B0=D0=B8=D0=B4=20=D0=9E=D0=BC=D0=B0=D1=80=20?= =?UTF-8?q?=D0=9C=D0=B5=D0=B4=D1=85=D0=B0=D1=82=20=7C=20Zaid=20Omar=20Medh?= =?UTF-8?q?at?= Date: Tue, 27 Jan 2026 15:00:23 +0500 Subject: [PATCH] fix --- src/auth/auth.service.ts | 2 +- src/users/users.service.ts | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index 73d456d..1429e39 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -129,7 +129,7 @@ export class AuthService { secure: isProduction || cookieSecure, sameSite: "none" as const, path: isRefreshToken ? "/auth/refresh" : "/", - domain: domain?.startsWith(".") ? domain : `.${domain}`, + domain: domain, maxAge: isRefreshToken ? 7 * 24 * 60 * 60 * 1000 : 15 * 60 * 1000, }; } diff --git a/src/users/users.service.ts b/src/users/users.service.ts index e76e390..2efdd4a 100644 --- a/src/users/users.service.ts +++ b/src/users/users.service.ts @@ -1,9 +1,9 @@ -import { Injectable, OnModuleInit } from '@nestjs/common'; -import { InjectRepository } from '@nestjs/typeorm'; -import { Repository } from 'typeorm'; -import { ConfigService } from '@nestjs/config'; -import * as bcrypt from 'bcrypt'; -import { User } from './entities'; +import { Injectable, OnModuleInit } from "@nestjs/common"; +import { InjectRepository } from "@nestjs/typeorm"; +import { Repository } from "typeorm"; +import { ConfigService } from "@nestjs/config"; +import * as bcrypt from "bcrypt"; +import { User } from "./entities"; @Injectable() export class UsersService implements OnModuleInit { @@ -18,14 +18,14 @@ export class UsersService implements OnModuleInit { } private async seedAdminUser() { - const adminUsername = this.configService.get('ADMIN_USERNAME') || 'admin'; + const adminUsername = + this.configService.get("ADMIN_USERNAME") || "admin"; const existingAdmin = await this.usersRepository.findOne({ where: { username: adminUsername }, }); if (!existingAdmin) { - // Create admin without password - requires setup on first login const admin = this.usersRepository.create({ username: adminUsername, password: null, @@ -33,7 +33,9 @@ export class UsersService implements OnModuleInit { isPasswordSet: false, }); await this.usersRepository.save(admin); - console.log(`Admin user "${adminUsername}" created - password setup required`); + console.log( + `Admin user "${adminUsername}" created - password setup required`, + ); } } @@ -63,7 +65,7 @@ export class UsersService implements OnModuleInit { async setupPassword(username: string, password: string): Promise { const user = await this.findByUsername(username); if (!user) { - throw new Error('User not found'); + throw new Error("User not found"); } const hashedPassword = await bcrypt.hash(password, 10);