blob: 3740b90b01e6a76dd053179052c18229e709c56a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import { NextRequest, NextResponse } from "next/server";
import { createUserServiceClient } from "@/client/client";
import { RequestBody, ResponseBody } from "./types";
import { getSession, withApiAuthRequired } from "@auth0/nextjs-auth0";
export const PUT = withApiAuthRequired(async function(req: NextRequest) {
const res = new NextResponse();
const session = await getSession(req, res);
if (!session || !session.user["sub"]) {
return res;
}
const { username, password } = RequestBody.parse(await req.json());
const client = createUserServiceClient();
await client.updateUser({
user: {
subject: session.user.sub,
ibdUsername: username,
ibdPassword: password,
},
updateMask: {
paths: ["ibd_username", "ibd_password"],
},
});
const ret: ResponseBody = {};
return NextResponse.json(ret, { status: 200 });
});
|