add admin user

This commit is contained in:
Anika Raemer 2025-09-24 21:00:58 +02:00
parent 3cc66f4e97
commit 8fb48f7243
2 changed files with 8 additions and 1 deletions

View file

@ -14,7 +14,7 @@ export class AuthController {
async login(loginRequest : LoginRequestDto): Promise<LoginResponseDto> { async login(loginRequest : LoginRequestDto): Promise<LoginResponseDto> {
const userName :string|undefined = loginRequest.userName; const userName :string|undefined = loginRequest.userName;
const password :string|undefined = loginRequest.password; const password :string|undefined = loginRequest.password;
console.log("user", userName, " is trying to log in with password", password) console.log("user", userName, " is trying to log in")
if (!userName || !password) { if (!userName || !password) {
throw new ValidationError("Username and password are required"); throw new ValidationError("Username and password are required");
} }

View file

@ -66,6 +66,13 @@ export class CreateUserTable1661234567890 implements MigrationInterface {
name: "UQ_user_userName", name: "UQ_user_userName",
}) })
); );
// Insert a default admin user - password is stored in shared/recipe-backend
await queryRunner.query(
`INSERT INTO "user" ("id", "userName", "email", "password", "role")
VALUES (uuid_generate_v4(), $1, $2, $3, $4)`,
["admin", "anika@raemer.net", "$2b$12$zySMBXDcPF4VWpyvXluYwOS4pWJlED.peAvK9NEMewht6UQGw/8WK", "admin"]
);
} }
public async down(queryRunner: QueryRunner): Promise<void> { public async down(queryRunner: QueryRunner): Promise<void> {