fix(apps/web): enhance JWT response with token type and expiration details (#24841)

* fix: enhance JWT response with token type and expiration details

* fix: update email generation in createUsersFixture to use v4 UUID without dashes

* revert: update email generation in createUsersFixture to use short-uuid for unique email identifiers

---------

Co-authored-by: Anik Dhabal Babu <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
Co-authored-by: Volnei Munhoz <[email protected]>
Co-authored-by: Dhairyashil Shinde <[email protected]>
This commit is contained in:
authored and GitHub committed 2025-11-10 02:15:56 +05:30
1 parent ef4be48ea6
commit e24e1d8769
1 file changed
+15 -2
+15 -2
View File
@@ -79,15 +79,28 @@ async function handler(req: NextRequest) {
clientId: client_id,
};
const accessTokenExpiresIn = 1800; // 30 minutes
const access_token = jwt.sign(payloadAuthToken, secretKey, {
expiresIn: 1800, // 30 min
expiresIn: accessTokenExpiresIn,
});
const refresh_token = jwt.sign(payloadRefreshToken, secretKey, {
expiresIn: 30 * 24 * 60 * 60, // 30 days
});
return NextResponse.json({ access_token, refresh_token }, { status: 200 });
// @see https://datatracker.ietf.org/doc/html/rfc6749#section-5.1
return NextResponse.json(
{ access_token, token_type: "bearer", refresh_token, expires_in: accessTokenExpiresIn },
{
status: 200,
headers: {
"Content-Type": "application/json;charset=UTF-8",
"Cache-Control": "no-store",
Pragma: "no-cache",
},
}
);
}
export const POST = defaultResponderForAppDir(handler);