Compare commits
2 Commits
7036338b33
...
5302cb9d72
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5302cb9d72 | ||
![]() |
357eb2b761 |
@ -3,14 +3,24 @@
|
|||||||
<div class="view active">
|
<div class="view active">
|
||||||
<h1>👋 Welcome! <a v-if="isAdmin" href="/auth/admin/" class="admin-link" title="Admin Console">Admin</a></h1>
|
<h1>👋 Welcome! <a v-if="isAdmin" href="/auth/admin/" class="admin-link" title="Admin Console">Admin</a></h1>
|
||||||
<div v-if="authStore.userInfo?.user" class="user-info">
|
<div v-if="authStore.userInfo?.user" class="user-info">
|
||||||
<h3>
|
<h3 class="user-name-heading">
|
||||||
👤
|
<span class="icon">👤</span>
|
||||||
<template v-if="!editingName">{{ authStore.userInfo.user.user_name }} <button class="mini-btn" @click="startEdit" title="Edit name">✏️</button></template>
|
<span v-if="!editingName" class="user-name-row">
|
||||||
<template v-else>
|
<span class="display-name" :title="authStore.userInfo.user.user_name">{{ authStore.userInfo.user.user_name }}</span>
|
||||||
<input v-model="newName" :placeholder="authStore.userInfo.user.user_name" :disabled="authStore.isLoading" maxlength="64" @keyup.enter="saveName" />
|
<button class="mini-btn" @click="startEdit" title="Edit name">✏️</button>
|
||||||
<button class="mini-btn" @click="saveName" :disabled="authStore.isLoading">💾</button>
|
</span>
|
||||||
<button class="mini-btn" @click="cancelEdit" :disabled="authStore.isLoading">✖</button>
|
<span v-else class="user-name-row editing">
|
||||||
</template>
|
<input
|
||||||
|
v-model="newName"
|
||||||
|
class="name-input"
|
||||||
|
:placeholder="authStore.userInfo.user.user_name"
|
||||||
|
:disabled="authStore.isLoading"
|
||||||
|
maxlength="64"
|
||||||
|
@keyup.enter="saveName"
|
||||||
|
/>
|
||||||
|
<button class="mini-btn" @click="saveName" :disabled="authStore.isLoading" title="Save name">💾</button>
|
||||||
|
<button class="mini-btn" @click="cancelEdit" :disabled="authStore.isLoading" title="Cancel">✖</button>
|
||||||
|
</span>
|
||||||
</h3>
|
</h3>
|
||||||
<span><strong>Visits:</strong></span>
|
<span><strong>Visits:</strong></span>
|
||||||
<span>{{ authStore.userInfo.user.visits || 0 }}</span>
|
<span>{{ authStore.userInfo.user.visits || 0 }}</span>
|
||||||
@ -186,7 +196,61 @@ async function saveName() {
|
|||||||
.user-info span {
|
.user-info span {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
.mini-btn { font-size: 0.7em; margin-left: 0.3em; }
|
.user-name-heading {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.4rem;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
margin: 0 0 0.25rem 0;
|
||||||
|
}
|
||||||
|
.user-name-row {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.35rem;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
.user-name-row.editing { flex: 1 1 auto; }
|
||||||
|
.icon { flex: 0 0 auto; }
|
||||||
|
.display-name {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 1.05em;
|
||||||
|
line-height: 1.2;
|
||||||
|
max-width: 14ch;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.name-input {
|
||||||
|
width: auto;
|
||||||
|
flex: 1 1 140px;
|
||||||
|
min-width: 120px;
|
||||||
|
padding: 6px 8px;
|
||||||
|
font-size: 0.9em;
|
||||||
|
border: 1px solid #a9c5d6;
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
.user-name-heading .name-input { width: auto; }
|
||||||
|
.name-input:focus { outline: 2px solid #667eea55; border-color: #667eea; }
|
||||||
|
.mini-btn {
|
||||||
|
width: auto;
|
||||||
|
padding: 4px 6px;
|
||||||
|
margin: 0;
|
||||||
|
font-size: 0.75em;
|
||||||
|
line-height: 1;
|
||||||
|
background: #eef5fa;
|
||||||
|
border: 1px solid #b7d2e3;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.2s, transform 0.15s;
|
||||||
|
}
|
||||||
|
.mini-btn:hover:not(:disabled) { background: #dcecf6; }
|
||||||
|
.mini-btn:active:not(:disabled) { transform: translateY(1px); }
|
||||||
|
.mini-btn:disabled { opacity: 0.5; cursor: not-allowed; }
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.user-name-heading { flex-direction: column; align-items: flex-start; }
|
||||||
|
.user-name-row.editing { width: 100%; }
|
||||||
|
.display-name { max-width: 100%; }
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -138,20 +138,20 @@ def main():
|
|||||||
|
|
||||||
default_port = DEFAULT_DEV_PORT if args.command == "dev" else DEFAULT_SERVE_PORT
|
default_port = DEFAULT_DEV_PORT if args.command == "dev" else DEFAULT_SERVE_PORT
|
||||||
host, port, uds, all_ifaces = parse_endpoint(args.hostport, default_port)
|
host, port, uds, all_ifaces = parse_endpoint(args.hostport, default_port)
|
||||||
reload_enabled = args.command == "dev"
|
devmode = args.command == "dev"
|
||||||
|
|
||||||
# Determine origin (dev mode default override)
|
# Determine origin (dev mode default override)
|
||||||
effective_origin = args.origin
|
origin = args.origin
|
||||||
if reload_enabled and not effective_origin:
|
if devmode and not args.origin and not args.rp_id:
|
||||||
# Use a distinct port (4403) for RP origin in dev if not explicitly provided
|
# Dev mode: Vite runs on another port, override:
|
||||||
effective_origin = "http://localhost:4403"
|
origin = "http://localhost:4403"
|
||||||
|
|
||||||
# Export configuration via environment for lifespan initialization in each process
|
# Export configuration via environment for lifespan initialization in each process
|
||||||
os.environ.setdefault("PASSKEY_RP_ID", args.rp_id)
|
os.environ.setdefault("PASSKEY_RP_ID", args.rp_id)
|
||||||
if args.rp_name:
|
if args.rp_name:
|
||||||
os.environ["PASSKEY_RP_NAME"] = args.rp_name
|
os.environ["PASSKEY_RP_NAME"] = args.rp_name
|
||||||
if effective_origin:
|
if origin:
|
||||||
os.environ["PASSKEY_ORIGIN"] = effective_origin
|
os.environ["PASSKEY_ORIGIN"] = origin
|
||||||
|
|
||||||
# One-time initialization + bootstrap before starting any server processes.
|
# One-time initialization + bootstrap before starting any server processes.
|
||||||
# Lifespan in worker processes will call globals.init with bootstrap disabled.
|
# Lifespan in worker processes will call globals.init with bootstrap disabled.
|
||||||
@ -161,7 +161,7 @@ def main():
|
|||||||
_globals.init(
|
_globals.init(
|
||||||
rp_id=args.rp_id,
|
rp_id=args.rp_id,
|
||||||
rp_name=args.rp_name,
|
rp_name=args.rp_name,
|
||||||
origin=effective_origin,
|
origin=origin,
|
||||||
default_admin=os.getenv("PASSKEY_DEFAULT_ADMIN") or None,
|
default_admin=os.getenv("PASSKEY_DEFAULT_ADMIN") or None,
|
||||||
default_org=os.getenv("PASSKEY_DEFAULT_ORG") or None,
|
default_org=os.getenv("PASSKEY_DEFAULT_ORG") or None,
|
||||||
bootstrap=True,
|
bootstrap=True,
|
||||||
@ -169,7 +169,7 @@ def main():
|
|||||||
)
|
)
|
||||||
|
|
||||||
run_kwargs: dict = {
|
run_kwargs: dict = {
|
||||||
"reload": reload_enabled,
|
"reload": devmode,
|
||||||
"log_level": "info",
|
"log_level": "info",
|
||||||
}
|
}
|
||||||
if uds:
|
if uds:
|
||||||
@ -181,7 +181,7 @@ def main():
|
|||||||
run_kwargs["port"] = port
|
run_kwargs["port"] = port
|
||||||
|
|
||||||
bun_process: subprocess.Popen | None = None
|
bun_process: subprocess.Popen | None = None
|
||||||
if reload_enabled:
|
if devmode:
|
||||||
# Spawn frontend dev server (bun) only in the original parent (avoid duplicates on reload)
|
# Spawn frontend dev server (bun) only in the original parent (avoid duplicates on reload)
|
||||||
if os.environ.get("PASSKEY_BUN_PARENT") != "1":
|
if os.environ.get("PASSKEY_BUN_PARENT") != "1":
|
||||||
os.environ["PASSKEY_BUN_PARENT"] = "1"
|
os.environ["PASSKEY_BUN_PARENT"] = "1"
|
||||||
@ -189,7 +189,7 @@ def main():
|
|||||||
if (frontend_dir / "package.json").exists():
|
if (frontend_dir / "package.json").exists():
|
||||||
try:
|
try:
|
||||||
bun_process = subprocess.Popen(
|
bun_process = subprocess.Popen(
|
||||||
["bun", "run", "dev"], cwd=str(frontend_dir)
|
["bun", "--bun", "run", "dev"], cwd=str(frontend_dir)
|
||||||
)
|
)
|
||||||
logging.info("Started bun dev server")
|
logging.info("Started bun dev server")
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
@ -213,7 +213,7 @@ def main():
|
|||||||
|
|
||||||
if all_ifaces and not uds:
|
if all_ifaces and not uds:
|
||||||
# If reload enabled, fallback to single dual-stack attempt (::) to keep reload simple
|
# If reload enabled, fallback to single dual-stack attempt (::) to keep reload simple
|
||||||
if reload_enabled:
|
if devmode:
|
||||||
run_kwargs["host"] = "::"
|
run_kwargs["host"] = "::"
|
||||||
run_kwargs["port"] = port
|
run_kwargs["port"] = port
|
||||||
uvicorn.run("passkey.fastapi:app", **run_kwargs)
|
uvicorn.run("passkey.fastapi:app", **run_kwargs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user