Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e7cf7f8946 | |||
| 1a1196b740 |
@@ -97,7 +97,7 @@ services:
|
|||||||
|
|
||||||
networks:
|
networks:
|
||||||
default:
|
default:
|
||||||
name: mb-grid-solutions-internal
|
name: ${PROJECT_NAME:-mb-grid-solutions}-internal
|
||||||
infra:
|
infra:
|
||||||
external: true
|
external: true
|
||||||
|
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
import { getPayload } from "payload";
|
|
||||||
import config from "./src/payload/payload.config";
|
|
||||||
|
|
||||||
const createAdmin = async () => {
|
|
||||||
const payload = await getPayload({ config });
|
|
||||||
|
|
||||||
const email = "marc@mintel.me";
|
|
||||||
const password = "Tim300493.";
|
|
||||||
|
|
||||||
console.log(`Creating/Updating admin: ${email}`);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Check if user exists
|
|
||||||
const users = await payload.find({
|
|
||||||
collection: "users",
|
|
||||||
where: {
|
|
||||||
email: {
|
|
||||||
equals: email,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (users.totalDocs > 0) {
|
|
||||||
console.log("User already exists. Updating password.");
|
|
||||||
await payload.update({
|
|
||||||
collection: "users",
|
|
||||||
id: users.docs[0].id,
|
|
||||||
data: {
|
|
||||||
password,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await payload.create({
|
|
||||||
collection: "users",
|
|
||||||
data: {
|
|
||||||
email,
|
|
||||||
password,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
console.log("Admin user created successfully.");
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error creating admin:", error);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
process.exit(0);
|
|
||||||
};
|
|
||||||
|
|
||||||
createAdmin();
|
|
||||||
Reference in New Issue
Block a user