perchitis
This commit is contained in:
parent
dfaab3a290
commit
d6f21728da
|
@ -74,7 +74,7 @@ export async function POST(request: Request) {
|
|||
);
|
||||
}
|
||||
|
||||
let avatarBuf: Buffer | undefined;
|
||||
let avatarBuf: Buffer | null | undefined;
|
||||
|
||||
if (avatarBase64 !== null && typeof avatarBase64 === "string") {
|
||||
avatarBuf = Buffer.from(avatarBase64, "base64");
|
||||
|
@ -112,7 +112,7 @@ export async function POST(request: Request) {
|
|||
}
|
||||
}
|
||||
|
||||
await ldap.createUser(username, displayName, email, avatarBuf);
|
||||
await ldap.createUser(username, displayName, email, avatarBuf ?? undefined);
|
||||
await ldap.setPassword(username, password);
|
||||
|
||||
const outputUser = await prisma.user.update({
|
||||
|
|
|
@ -5,7 +5,7 @@ import { getLogger } from "@/logger";
|
|||
type RequestBody = {
|
||||
displayName?: string;
|
||||
email?: string;
|
||||
avatarBase64?: string;
|
||||
avatar?: string;
|
||||
};
|
||||
|
||||
export async function POST(request: Request) {
|
||||
|
@ -20,8 +20,11 @@ export async function POST(request: Request) {
|
|||
return new Response(null, { status: 409 });
|
||||
}
|
||||
|
||||
const { displayName, email, avatarBase64 } =
|
||||
(await request.json()) as RequestBody;
|
||||
const {
|
||||
displayName,
|
||||
email,
|
||||
avatar: avatarBase64
|
||||
} = (await request.json()) as RequestBody;
|
||||
|
||||
let changeDisplayName = false;
|
||||
if (
|
||||
|
@ -77,7 +80,7 @@ export async function POST(request: Request) {
|
|||
username: user.username,
|
||||
displayName: changeDisplayName ? displayName : null,
|
||||
email: changeEmail ? email : null,
|
||||
avatar: avatarBuf ? avatarBuf.toString("base64") : null
|
||||
avatar: avatarBuf ? `${avatarBuf.length} bytes` : null
|
||||
},
|
||||
"updated user"
|
||||
);
|
||||
|
|
|
@ -10,7 +10,7 @@ export type DiscordAccessTokenResponse = {
|
|||
|
||||
export type DiscordUserResponse = {
|
||||
id: string;
|
||||
avatar: string;
|
||||
avatar: string | null;
|
||||
};
|
||||
|
||||
export type DiscordGuildResponse = {
|
||||
|
@ -49,6 +49,7 @@ export async function getDiscordAvatar(token: string) {
|
|||
});
|
||||
|
||||
const res: DiscordUserResponse = await req.json();
|
||||
if (res.avatar === null) return null;
|
||||
const file = `https://cdn.discordapp.com/avatars/${res.id}/${res.avatar}.png`;
|
||||
|
||||
const avatarReq = await fetch(file);
|
||||
|
|
Loading…
Reference in New Issue