Skip to content

Commit 1b57691

Browse files
committed
fix: prevent duplicate Default configs and update openboot avatar URL
- OAuth callbacks now check user has zero configs instead of checking for slug='default' - Fixes duplicate Default config creation when users already have uploaded configs - Updated openboot user avatar URL to GitHub org avatar
1 parent 4625b5e commit 1b57691

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

migrations/0009_seed_configs.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Seed official openboot user and 20 curated starter configs
22

33
INSERT INTO users (id, username, email, avatar_url)
4-
VALUES ('openboot-official', 'openboot', 'hello@openboot.dev', 'https://github.com/openbootdev.png');
4+
VALUES ('openboot-official', 'openboot', 'hello@openboot.dev', 'https://avatars.githubusercontent.com/u/258731499?v=4');
55

66
-- 1. Frontend - React
77
INSERT INTO configs (id, user_id, slug, name, description, base_preset, packages, custom_script, visibility, alias, dotfiles_repo, install_count, featured)

src/routes/api/auth/callback/github/+server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ export const GET: RequestHandler = async ({ url, platform, cookies, request }) =
8585
.bind(userId, username, email, githubUser.avatar_url || '')
8686
.run();
8787

88-
const existingConfig = await env.DB.prepare('SELECT id FROM configs WHERE user_id = ? AND slug = ?').bind(userId, 'default').first();
88+
const configCount = await env.DB.prepare('SELECT COUNT(*) as count FROM configs WHERE user_id = ?').bind(userId).first<{ count: number }>();
8989

90-
if (!existingConfig) {
90+
if (!configCount || configCount.count === 0) {
9191
await env.DB.prepare(
9292
`
9393
INSERT INTO configs (id, user_id, slug, name, description, base_preset, packages)

src/routes/api/auth/callback/google/+server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ export const GET: RequestHandler = async ({ url, platform, cookies, request }) =
8787
.bind(userId, username, googleUser.email, googleUser.picture || '')
8888
.run();
8989

90-
const existingConfig = await env.DB.prepare('SELECT id FROM configs WHERE user_id = ? AND slug = ?').bind(userId, 'default').first();
90+
const configCount = await env.DB.prepare('SELECT COUNT(*) as count FROM configs WHERE user_id = ?').bind(userId).first<{ count: number }>();
9191

92-
if (!existingConfig) {
92+
if (!configCount || configCount.count === 0) {
9393
await env.DB.prepare(
9494
`
9595
INSERT INTO configs (id, user_id, slug, name, description, base_preset, packages)

0 commit comments

Comments
 (0)