diff --git a/README.md b/README.md index 54bf956..834ccb7 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,22 @@ PlebDevs is an open-source platform that combines educational content, community - Admin pubkey management - Content pricing controls +### Running locally + +1. Clone the repository +2. Install dependencies +3. Create a `.env` file based on the `.env.example` file +4. Open Docker Desktop +5. Run `docker compose up --build` +6. In schema.prisma, ensure you have the local datasource uncommented and the production datasource commented out. +7. Exec into the container and run `npx prisma migrate dev` +8. Restart the docker compose +9. Rerun `docker compose up --build` + +Now the database is running and the migrations are applied. +You can now run locally. + + ## Contributing Contributions are welcome! Whether you're fixing bugs, improving documentation, or proposing new features, please feel free to open an issue or submit a PR. diff --git a/src/pages/api/auth/[...nextauth].js b/src/pages/api/auth/[...nextauth].js index abaace9..130f3cf 100644 --- a/src/pages/api/auth/[...nextauth].js +++ b/src/pages/api/auth/[...nextauth].js @@ -50,6 +50,20 @@ const syncNostrProfile = async (pubkey) => { await updateUser(dbUser.id, updates); dbUser = await getUserByPubkey(pubkey); } + + // Check if user should have author role but doesn't + if (appConfig.authorPubkeys.includes(pubkey) && !dbUser.role?.admin) { + const role = await createRole({ + userId: dbUser.id, + admin: true, + subscribed: false, + }); + + if (role) { + await updateUser(dbUser.id, { role: role.id }); + dbUser = await getUserByPubkey(pubkey); + } + } } else { // Create new user const username = fields.username || pubkey.slice(0, 8);