fix: typescript sux
This commit is contained in:
parent
cc100d632c
commit
cd04773504
@ -1,13 +1,13 @@
|
|||||||
|
// SHUT THE FUCK UP
|
||||||
|
// deno-lint-ignore-file no-explicit-any
|
||||||
import JWT from "../../utils/JWT.ts";
|
import JWT from "../../utils/JWT.ts";
|
||||||
import HttpError from "../HttpError.ts";
|
import HttpError from "../HttpError.ts";
|
||||||
import Router, { makeParameterModifier } from "../Router.ts";
|
import Router, { makeParameterModifier } from "../Router.ts";
|
||||||
|
|
||||||
// SHUT THE FUCK UP
|
export default function jwt<T extends Router = any>(salt: ((self: T) => string) | string, required = false) {
|
||||||
// deno-lint-ignore no-explicit-any
|
|
||||||
export default function jwt<T extends Router = any>(salt: ((self: T) => string) | keyof T, required = false) {
|
|
||||||
return makeParameterModifier<T>(function (_req, val?: string) {
|
return makeParameterModifier<T>(function (_req, val?: string) {
|
||||||
if (val === undefined) return undefined;
|
if (val === undefined) return undefined;
|
||||||
const s = typeof salt === 'function' ? salt(this) : this[salt] as string;
|
const s = typeof salt === 'function' ? salt(this) : (this as any)[salt] as string;
|
||||||
try {
|
try {
|
||||||
const res = JWT.decode(val, s);
|
const res = JWT.decode(val, s);
|
||||||
if (required && res === undefined) throw new HttpError('You are not logged in.');
|
if (required && res === undefined) throw new HttpError('You are not logged in.');
|
||||||
|
Loading…
Reference in New Issue
Block a user