Skip to content

Commit

Permalink
Add instruction for mailer and admin panel setup for node version (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
byn9826 authored Sep 6, 2024
1 parent af90b15 commit 393a408
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion admin-panel/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NEXT_PUBLIC_CLIENT_URI=http://localhost:3000 # Replace with the host of your react app
NEXT_PUBLIC_CLIENT_URI=http://localhost:3000 # Replace with the host of your admin panel app
NEXT_PUBLIC_SERVER_URI=http://localhost:8787 # Replace with your melody-auth server base uri
NEXT_PUBLIC_CLIENT_ID= # Put your admin panel SPA clientId here
SERVER_CLIENT_ID= # Put your admin panel S2S clientId here
Expand Down
14 changes: 10 additions & 4 deletions docs/admin-panel.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@ cp .env.example .env

## 3. Update the .env file with the following variables:
```
NEXT_PUBLIC_SERVER_URI: Set this to your Cloudflare worker URL where you hosted the auth server, or use http://localhost:8787 for local development.
NEXT_PUBLIC_CLIENT_URI: Set this to the host url of your admin panel app
NEXT_PUBLIC_SERVER_URI: Set this to the host url of your auth server.
NEXT_PUBLIC_CLIENT_ID: Client ID for the Admin Panel (SPA) app
SERVER_CLIENT_ID: Client ID for the Admin Panel (S2S) app
SERVER_CLIENT_SECRET: Client secret for the Admin Panel (S2S) app
```

- For production, you can find the necessary information in the Cloudflare dashboard under "Workers & Pages" -> D1 -> Melody Auth database -> app table.
- For local development, use the following command to retrieve app information:
- For Cloudflare production, you can find the necessary information in the Cloudflare dashboard under "Workers & Pages" -> D1 -> Melody Auth database -> app table.
- For Cloudflare local development, use the following command to retrieve app information:
```
cd melody-auth/server
wrangler d1 execute melody-auth --command="select * from app"
```
- For Node version, check your Postgres melody-auth database -> app table

## 4. Start the admin panel app

Expand All @@ -41,7 +43,7 @@ npm run dev
1. When you first access the admin panel, you'll be redirected to the Melody Auth screen. Create a new account.
2. After creating an account, you'll be redirected back to the admin panel with an "super_admin role required" alert. This is expected for new accounts.
3. To grant super admin access:
- For production:
- For Cloudflare production:
1. Go to the Cloudflare dashboard
2. Navigate to "Workers & Pages" -> D1 -> Melody Auth database -> user_role table
3. Add a new record with userId = 1 and roleId = 1 (assuming you just created the first user)
Expand All @@ -50,4 +52,8 @@ npm run dev
cd melody-auth/server
wrangler d1 execute melody-auth --command="insert into user_role (userId, roleId) values (1, 1)"
```
- For Node version, insert following record to your Postgres melody-auth database:
```
insert into user_role (userId, roleId) values (1, 1)
```
4. Logout (Required after update user role) and login again. You should now have full access.
5 changes: 4 additions & 1 deletion docs/auth-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Melody Auth supports email-based features such as password reset, email verifica
- SendGrid/Brevo API key
- Verified sender email address in SendGrid/Brevo

### Configuration Steps
### Configuration Steps (Cloudflare Production)

1. Navigate to the Cloudflare dashboard:
- Go to Workers & Pages
Expand All @@ -142,6 +142,9 @@ Melody Auth supports email-based features such as password reset, email verifica

3. Click "Save and deploy" to apply the changes.

### Configuration Steps (Cloudflare Local or Node)
Update environment variables in server/.dev.vars file accordingly.

### Environment Behavior

- When `ENVIRONMENT` is set to "prod":
Expand Down

0 comments on commit 393a408

Please sign in to comment.