MCPcopy Index your code
hub / github.com/21st-dev/1code / updateUser

Method updateUser

src/main/auth-manager.ts:228–253  ·  view source on GitHub ↗

* Update user profile on server and locally

(updates: { name?: string })

Source from the content-addressed store, hash-verified

226 * Update user profile on server and locally
227 */
228 async updateUser(updates: { name?: string }): Promise<AuthUser | null> {
229 const token = await this.getValidToken()
230 if (!token) {
231 throw new Error("Not authenticated")
232 }
233
234 // Update on server using X-Desktop-Token header
235 const response = await fetch(`${this.getApiUrl()}/api/user/profile`, {
236 method: "PATCH",
237 headers: {
238 "Content-Type": "application/json",
239 "X-Desktop-Token": token,
240 },
241 body: JSON.stringify({
242 display_name: updates.name,
243 }),
244 })
245
246 if (!response.ok) {
247 const error = await response.json().catch(() => ({ error: "Unknown error" }))
248 throw new Error(error.error || `Update failed: ${response.status}`)
249 }
250
251 // Update locally
252 return this.store.updateUser({ name: updates.name ?? null })
253 }
254
255 /**
256 * Fetch user's subscription plan from web backend

Callers

nothing calls this directly

Calls 2

getValidTokenMethod · 0.95
getApiUrlMethod · 0.95

Tested by

no test coverage detected