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);