* update oauth tests * fix parseRequestData * add logging * add fallback * use ?? * updates * use parseUrlFormData in saml/callback * update tests * fix * remove log * update * any -> unknown * use HttpErrors * addressed * unknown -> any * feat: Add entry report wrapper to every api route in appDir * fix * fix unit test * fix
20 lines
750 B
TypeScript
20 lines
750 B
TypeScript
import { defaultResponderForAppDir } from "app/api/defaultResponderForAppDir";
|
|
import { NextResponse } from "next/server";
|
|
import type { NextRequest } from "next/server";
|
|
|
|
import isAuthorized from "@calcom/features/auth/lib/oAuthAuthorization";
|
|
|
|
async function handler(req: NextRequest) {
|
|
const requiredScopes = ["READ_PROFILE"];
|
|
const token = req.headers.get("authorization")?.split(" ")[1] || "";
|
|
const account = await isAuthorized(token, requiredScopes);
|
|
|
|
if (!account) {
|
|
return NextResponse.json({ message: "Unauthorized" }, { status: 401 });
|
|
}
|
|
|
|
return NextResponse.json({ username: account.name }, { status: 201 });
|
|
}
|
|
export const GET = defaultResponderForAppDir(handler);
|
|
export const POST = defaultResponderForAppDir(handler);
|