2024-02-24 11:18:58 +02:00
|
|
|
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
|
|
|
|
|
|
|
|
import { validateApiToken } from '@documenso/lib/server-only/webhooks/zapier/validateApiToken';
|
|
|
|
|
|
|
|
|
|
export const testCredentialsHandler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|
|
|
|
try {
|
|
|
|
|
const { authorization } = req.headers;
|
2024-02-26 22:24:23 +11:00
|
|
|
|
2024-02-27 15:22:02 +02:00
|
|
|
const result = await validateApiToken({ authorization });
|
2024-02-24 11:18:58 +02:00
|
|
|
|
|
|
|
|
return res.status(200).json({
|
2024-02-27 15:22:02 +02:00
|
|
|
name: result.userId ? result.user.name : result.team?.name,
|
2024-02-24 11:18:58 +02:00
|
|
|
});
|
|
|
|
|
} catch (err) {
|
|
|
|
|
return res.status(500).json({
|
|
|
|
|
message: 'Internal Server Error',
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|