Something went wrong. Try again.
Web frontend and supporting services for lance.blue
Something went wrong. Try again.
1.6 kB · 40 lines
Shell
1234567891011121314151617181920212223242526272829303132333435363738394041#!/usr/bin/env bash# Seeds a signed-in session into a scripts/dev-instance.sh instance and# prints the cookie value - the piece devauth.ts's VITE_LOCAL_AUTH=1 does# not cover, since it fakes only the frontend's sign-in and never touches# headquarters-api, so a screen that calls the API as a signed-in player# still sees no session under it.## scripts/dev-session.sh STATE_DIR [DID] [HANDLE]## STATE_DIR is what `dev-instance.sh start` printed. DID defaults to a fixed# obviously-fake one; HANDLE is optional and, if given, also seeds an# `account` row so the UI has a real-looking handle to show instead of the# raw DID.## Prints exactly one line to stdout: the cookie value. Use it as a `Cookie:# headquarters_session=<value>` header, or as a raw `document.cookie`# equivalent injected at the network layer - it is HttpOnly, so page# JavaScript cannot set it itself.set -euo pipefail
cd "$(dirname "$0")/.."
state_dir="${1:?usage: $0 STATE_DIR [DID] [HANDLE]}"did="${2:-}"handle="${3:-}"
[ -f "$state_dir/db.sqlite" ] || { echo "dev-session: $state_dir/db.sqlite does not exist - did dev-instance.sh start run first?" >&2 exit 1}
# Where cargo puts the binary, in whichever worktree this is run from.target_dir="$(git rev-parse --show-toplevel)/target"export DEV_SESSION_DB="$state_dir/db.sqlite"export SESSION_SECRET="${SESSION_SECRET:-0123456789abcdef0123456789abcdef}"[ -n "$did" ] && export DEV_SESSION_DID="$did"[ -n "$handle" ] && export DEV_SESSION_HANDLE="$handle"
cargo build -p headquarters-api --bin dev_session -j 2 >&2"$target_dir/debug/dev_session"