fix: Add explicit error for missing auth token

This commit is contained in:
Tom Moor committed 2024-06-04 21:36:26 -04:00
1 parent 42f9971368
commit dd4c8c5546
1 file changed
+4 -1
+4 -1
View File
@@ -5,6 +5,9 @@ import { AuthenticationError } from "../errors";
export function getJWTPayload(token: string) {
let payload;
if (!token) {
throw AuthenticationError("Missing token");
}
try {
payload = JWT.decode(token);
@@ -15,7 +18,7 @@ export function getJWTPayload(token: string) {
return payload as JWT.JwtPayload;
} catch (err) {
throw AuthenticationError("Unable to decode JWT token");
throw AuthenticationError("Unable to decode token");
}
}