chore: add local account debugging scripts
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
parent
110112e9b4
commit
3597833843
2 changed files with 69 additions and 0 deletions
42
repro-account.ts
Normal file
42
repro-account.ts
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
import "dotenv/config";
|
||||||
|
import config from "./src/payload.config";
|
||||||
|
import { getPayload } from "payload";
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const payload = await getPayload({ config });
|
||||||
|
|
||||||
|
const login = await payload.login({
|
||||||
|
collection: "users",
|
||||||
|
data: { username: "dev", password: "Test123" },
|
||||||
|
});
|
||||||
|
const token = login.token;
|
||||||
|
console.log("login ok, token:", token ? token.slice(0, 20) + "..." : "(none)");
|
||||||
|
|
||||||
|
const headers = new Headers({ cookie: `payload-token=${token}` });
|
||||||
|
const { user } = await payload.auth({ headers, canSetHeaders: false });
|
||||||
|
console.log("auth user:", user?.id, user?.username, user ? "(defined)" : "(NULL)");
|
||||||
|
|
||||||
|
if (!user) throw new Error("no user from auth");
|
||||||
|
|
||||||
|
const fullUser = await payload.findByID({
|
||||||
|
collection: "users",
|
||||||
|
id: user.id,
|
||||||
|
depth: 0,
|
||||||
|
overrideAccess: true,
|
||||||
|
});
|
||||||
|
console.log("findByID(users) ok:", fullUser.id);
|
||||||
|
|
||||||
|
const profiles = await payload.find({
|
||||||
|
collection: "profiles",
|
||||||
|
where: { user: { equals: user.id } },
|
||||||
|
select: { progression: { xp: true } },
|
||||||
|
});
|
||||||
|
console.log("find(profiles) ok:", profiles.docs.length);
|
||||||
|
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch((err) => {
|
||||||
|
console.error("REPRO FAILED:", err);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
27
reset-test-user-password.ts
Normal file
27
reset-test-user-password.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
import { getPayload } from "payload";
|
||||||
|
import config from "@payload-config";
|
||||||
|
|
||||||
|
const payload = await getPayload({ config });
|
||||||
|
|
||||||
|
const userRes = await payload.find({
|
||||||
|
collection: "users",
|
||||||
|
where: { username: { equals: "mt-msmg3li2-buyer" } },
|
||||||
|
limit: 1,
|
||||||
|
overrideAccess: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!userRes.docs[0]) {
|
||||||
|
console.error("User not found");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Found user:", userRes.docs[0].username, userRes.docs[0].id);
|
||||||
|
|
||||||
|
await payload.update({
|
||||||
|
collection: "users",
|
||||||
|
id: userRes.docs[0].id,
|
||||||
|
data: { password: "Test123" },
|
||||||
|
overrideAccess: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("Password reset complete for mt-msmg3li2-buyer");
|
||||||
Loading…
Reference in a new issue