feat(user migration): user migration to the new app with a default password that will force reset

This commit is contained in:
2025-10-29 17:01:03 -05:00
parent c6f766089b
commit 006ec1bfc0
9 changed files with 127 additions and 24 deletions

View File

@@ -0,0 +1,34 @@
import { Client } from "pg";
import { auth } from "../../../pkg/auth/auth.js";
import { createLogger } from "../../../pkg/logger/logger.js";
export const userMigrate = async () => {
const log = createLogger({ module: "admin", subModule: "migrate users" });
const client = new Client({
connectionString: process.env.DATABASE_URL_V1,
});
await client.connect();
const res = await client.query(`
SELECT username, email
FROM users
`);
for (const u of res.rows) {
log.info({}, `${u.username}, being transferred`);
try {
await auth.api.signUpEmail({
body: {
username: u.username,
name: u.username,
email: u.email,
password: "Alpla2025!",
},
});
log.info({}, `${u.username}, transferred`);
} catch (e) {
log.info({}, `${u.username}, already existed`);
}
}
};

View File

@@ -53,7 +53,7 @@ router.post("/", async (req: Request, res: Response) => {
}
if (err instanceof APIError) {
return res.status(400).json({
return res.status(200).json({
success: false,
message: err.message,
error: err.status,

View File

@@ -0,0 +1,10 @@
import { readFileSync } from "fs";
import path from "path";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export const baseModules = async () => {
const modulePath = path.resolve(__dirname, "./modules.json");
};

View File

@@ -0,0 +1,30 @@
[
{
"name": "plantToken",
"value": "test3",
"description": "The plant token for the plant IE: test3 or usday1",
"moduleName": "system",
"roles": ["systemAdmin"]
},
{
"name": "dbServer",
"value": "usmcd1vms036",
"description": "What is the db server",
"moduleName": "system",
"roles": ["systemAdmin"]
},
{
"name": "v1Server",
"value": "localhost",
"description": "What is the port the v1app is on",
"moduleName": "system",
"roles": ["systemAdmin"]
},
{
"name": "v1Port",
"value": "3000",
"description": "What is the port the v1app is on",
"moduleName": "system",
"roles": ["systemAdmin"]
}
]