Remove desktop API key login

This commit is contained in:
Sreeram Sreedhar 2026-06-23 18:24:14 -07:00
parent bd419f7f20
commit 5f29b16685
4 changed files with 3 additions and 69 deletions

View file

@ -11,7 +11,6 @@ import { ExternalAuthButton } from "@ui/button/external-auth"
import { Badge } from "@ui/components/badge"
import { Button } from "@ui/components/button"
import { Input } from "@ui/components/input"
import { Label } from "@ui/components/label"
import { TextSeparator } from "@ui/components/text-separator"
import { Loader2 } from "lucide-react"
import { useRouter } from "next/navigation"
@ -24,19 +23,16 @@ import {
} from "react"
import {
beginSocialAuth,
desktopDevAuthEnabled,
getSession,
onAuthChanged,
onAuthError,
sendMagicLink,
storeToken,
verifyMagicLinkToken,
} from "@/lib/auth"
import { postAuthRedirectPath } from "@/lib/onboarding"
export default function LoginPage() {
const router = useRouter()
const [token, setToken] = useState("")
const [email, setEmail] = useState("")
const [submittedEmail, setSubmittedEmail] = useState<string | null>(null)
const [loginCode, setLoginCode] = useState("")
@ -86,21 +82,6 @@ export default function LoginPage() {
}
}, [router])
async function onSubmit(event: FormEvent<HTMLFormElement>) {
event.preventDefault()
setError(null)
setIsSubmitting(true)
try {
await storeToken(token)
router.replace(postAuthRedirectPath())
} catch (err) {
setError(formatError(err, "Could not sign in"))
} finally {
setIsSubmitting(false)
}
}
async function startSocialAuth(provider: "google" | "github") {
setError(null)
setSubmittedEmail(null)
@ -335,37 +316,6 @@ export default function LoginPage() {
{error}
</p>
) : null}
{desktopDevAuthEnabled ? (
<details className="group rounded-xl border border-white/5 bg-white/[0.02] px-4 py-3">
<summary className="cursor-pointer text-muted-foreground text-xs transition-colors hover:text-foreground">
Development API key
</summary>
<form
className="mt-4 space-y-3 text-left"
onSubmit={onSubmit}
>
<div className="space-y-2">
<Label htmlFor="api-key">API key</Label>
<Input
id="api-key"
value={token}
onChange={(event) => setToken(event.target.value)}
placeholder="sm_..."
type="password"
autoComplete="off"
/>
</div>
<Button
type="submit"
className="w-full"
disabled={!token.trim() || isSubmitting}
>
{isSubmitting ? "Checking..." : "Continue with key"}
</Button>
</form>
</details>
) : null}
</div>
</div>

View file

@ -10,7 +10,6 @@ export type AuthSession = {
apiUrl: string
}
export const desktopDevAuthEnabled = process.env.NEXT_PUBLIC_DESKTOP_DEV === "1"
export const AUTH_CHANGED_EVENT = "auth:changed"
export const AUTH_ERROR_EVENT = "auth:error"
@ -27,11 +26,6 @@ export async function getSession() {
return invoke<AuthSession>("auth_whoami")
}
export async function storeToken(token: string) {
await invoke("auth_store_token", { token })
return getSession()
}
export async function beginBrowserAuth() {
return invoke<string>("auth_begin_browser")
}

View file

@ -171,10 +171,6 @@ fn is_loopback_http_url(value: &str) -> bool {
.unwrap_or(false)
}
pub fn store_token(token: String) -> Result<(), String> {
store_token_with_api_url(token, Some(configured_api_url()))
}
pub fn store_token_with_api_url(token: String, api_url: Option<String>) -> Result<(), String> {
let token = token.trim();
if token.is_empty() {
@ -682,7 +678,7 @@ fn complete_browser_auth(parsed: url::Url) -> Result<(), String> {
return Err(format!("Browser sign-in failed: {error}"));
}
let api_key = params
let auth_token = params
.iter()
.find_map(|(key, value)| (key == "apikey").then(|| value.to_string()))
.or_else(|| {
@ -695,7 +691,7 @@ fn complete_browser_auth(parsed: url::Url) -> Result<(), String> {
.iter()
.find_map(|(key, value)| (key == "token").then(|| value.to_string()))
})
.ok_or_else(|| "Auth callback did not include API key".to_string())?;
.ok_or_else(|| "Auth callback did not include an auth token".to_string())?;
let callback_api_url = params
.iter()
.find_map(|(key, value)| (key == "apiUrl").then(|| value.to_string()))
@ -706,7 +702,7 @@ fn complete_browser_auth(parsed: url::Url) -> Result<(), String> {
});
store_token_with_api_url(
api_key,
auth_token,
callback_api_url.or_else(|| Some(browser_auth_api_url())),
)
}

View file

@ -29,11 +29,6 @@ fn app_info() -> AppInfo {
}
}
#[tauri::command]
fn auth_store_token(token: String) -> Result<(), String> {
auth::store_token(token)
}
#[tauri::command]
fn auth_get_token() -> Result<Option<String>, String> {
auth::get_token()
@ -224,7 +219,6 @@ pub fn run() {
})
.invoke_handler(tauri::generate_handler![
app_info,
auth_store_token,
auth_get_token,
auth_clear,
auth_begin_browser,