account auth cleanup
This commit is contained in:
parent
6162722c87
commit
94de501a49
5 changed files with 41 additions and 22 deletions
|
|
@ -16,7 +16,7 @@ export async function GET(req: Request) {
|
|||
|
||||
const res = await fetch(
|
||||
`${API}/users/me?fields=${encodeURIComponent(fields)}`,
|
||||
{ headers: { Authorization: bearer }, cache: "no-store" }
|
||||
{ headers: { Authorization: `Bearer ${bearer}` }, cache: "no-store" }
|
||||
);
|
||||
const j = await res.json().catch(() => ({}));
|
||||
|
||||
|
|
@ -40,19 +40,19 @@ export async function PATCH(req: Request) {
|
|||
|
||||
const payload: Record<string, any> = {};
|
||||
if (typeof body.first_name === "string") payload.first_name = body.first_name.trim();
|
||||
if (typeof body.last_name === "string") payload.last_name = body.last_name.trim();
|
||||
if (typeof body.last_name === "string") payload.last_name = body.last_name.trim();
|
||||
if ("email" in body) {
|
||||
const e = String(body.email ?? "").trim();
|
||||
payload.email = e ? e : null; // optional; blank clears
|
||||
}
|
||||
if (typeof body.location === "string") payload.location = body.location.trim();
|
||||
if (typeof body.avatar === "string") payload.avatar = body.avatar; // file id
|
||||
if (typeof body.location === "string") payload.location = body.location.trim();
|
||||
if (typeof body.avatar === "string") payload.avatar = body.avatar; // file id
|
||||
|
||||
if (!Object.keys(payload).length) return bad("No changes");
|
||||
|
||||
const res = await fetch(`${API}/users/me`, {
|
||||
method: "PATCH",
|
||||
headers: { Authorization: bearer, "Content-Type": "application/json" },
|
||||
headers: { Authorization: `Bearer ${bearer}`, "Content-Type": "application/json" },
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
const j = await res.json().catch(() => ({}));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue