Merge pull request 'feature/#70-static-user-login' (#97) from feature/#70-static-user-login into develop
Reviewed-on: #97
This commit is contained in:
commit
a64567ce4e
21 changed files with 395 additions and 79 deletions
39
src/migrations/1746252454922-UserLoginRoutine.ts
Normal file
39
src/migrations/1746252454922-UserLoginRoutine.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
import { MigrationInterface, QueryRunner, TableColumn } from "typeorm";
|
||||
import { getDefaultByORM, getTypeByORM } from "./ormHelper";
|
||||
import { LoginRoutineEnum } from "../enums/loginRoutineEnum";
|
||||
import { CodingHelper } from "../helpers/codingHelper";
|
||||
import { APPLICATION_SECRET } from "../env.defaults";
|
||||
|
||||
export class UserLoginRoutine1746252454922 implements MigrationInterface {
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
let users = await queryRunner.manager.getRepository("user").find({ select: ["id", "secret"] });
|
||||
|
||||
await queryRunner.dropColumns("user", ["secret", "static"]);
|
||||
|
||||
await queryRunner.addColumns("user", [
|
||||
new TableColumn({ name: "secret", ...getTypeByORM("text"), default: getDefaultByORM("string") }),
|
||||
new TableColumn({
|
||||
name: "routine",
|
||||
...getTypeByORM("varchar"),
|
||||
default: getDefaultByORM("string", LoginRoutineEnum.totp),
|
||||
}),
|
||||
]);
|
||||
|
||||
await queryRunner.manager.getRepository("user").save(users.map((u) => ({ id: u.id, secret: u.secret })));
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
let users = await queryRunner.manager.getRepository("user").find({ select: ["id", "secret"] });
|
||||
|
||||
await queryRunner.dropColumn("user", "secret");
|
||||
|
||||
await queryRunner.addColumns("user", [
|
||||
new TableColumn({ name: "secret", ...getTypeByORM("varchar"), default: getDefaultByORM("string") }),
|
||||
new TableColumn({ name: "static", ...getTypeByORM("boolean"), default: getDefaultByORM("boolean", false) }),
|
||||
]);
|
||||
|
||||
await queryRunner.manager.getRepository("user").save(users.map((u) => ({ id: u.id, secret: u.secret })));
|
||||
|
||||
await queryRunner.dropColumn("user", "routine");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue