···11import Alpine from "alpinejs";
22import { goto } from "../utils/tools.ts";
33import { Store } from "../utils/store.ts";
44-import { generateSignupKey } from "../utils/api.ts";
44+import * as api from "../utils/api.ts";
5566Alpine.data("homePageState", () => ({
77 friends: [
···3232 },
33333434 async generateSignupKey() {
3535- this.newSignupKey = await generateSignupKey();
3535+ this.newSignupKey = await api.generateSignupKey();
3636 },
37373838 isAdmin() {
+2-8
app/src/settings-page/settings.html
···8899 <body>
1010 <div class="card">
1111- <!-- x-data connects this element to the settingsPageState Alpine component, enabling its data (serverAddress and signupKey) and functions (signup and scanQR) to work within it :) -->
1212- <!-- TODO: make this a form instead? -->
1311 <div class="actions" x-data="settingsPageState">
1412 <h3>Settings</h3>
15131616- <button class="btn-secondary" @click="goto('home')">
1717- Back to Home
1818- </button>
1414+ <button class="btn-secondary" @click="goto('home')">Back to Home</button>
19152020- <button class="btn-secondary" @click="resetStore()">
2121- Signout
2222- </button>
1616+ <button class="btn-secondary" @click="await debugLogout()">Signout</button>
2317 </div>
2418 </div>
2519 </body>
···3232 return json;
3333}
34343535+// this api is laughably vulnerable to a replay attack currently, but not later with key chaining
3536export async function generateSignupKey(): Promise<string> {
3637 return await post("generate-signup-key");
3738}
+1-8
server/src/auth.rs
···2727 .and_then(|v| v.to_str().ok())
2828 .ok_or(SrvErr!("missing x-auth header"))?;
29293030- let decoded_auth = BASE64_STANDARD
3131- .decode(auth_header)
3232- .map_err(|e| SrvErr!("invalid base64 in x-auth header", e))?;
3333-3434- let auth_str = String::from_utf8(decoded_auth)
3535- .map_err(|e| SrvErr!("invalid utf8 in x-auth header", e))?;
3636-3737- let auth_data: AuthData = serde_json::from_str(&auth_str)
3030+ let auth_data: AuthData = serde_json::from_str(auth_header)
3831 .map_err(|e| SrvErr!("failed to parse x-auth JSON", e))?;
39324033 let users = state.users.lock().await;