mirror of
https://github.com/spacebarchat/server.git
synced 2026-08-06 23:19:47 +00:00
refactor checkToken
This commit is contained in:
@@ -92,12 +92,7 @@ export async function Authentication(
|
||||
Sentry.setUser({ id: req.user_id });
|
||||
|
||||
try {
|
||||
const { jwtSecret } = Config.get().security;
|
||||
|
||||
const { decoded, user } = await checkToken(
|
||||
req.headers.authorization,
|
||||
jwtSecret,
|
||||
);
|
||||
const { decoded, user } = await checkToken(req.headers.authorization);
|
||||
|
||||
req.token = decoded;
|
||||
req.user_id = decoded.id;
|
||||
|
||||
@@ -48,11 +48,9 @@ router.post(
|
||||
async (req: Request, res: Response) => {
|
||||
const { password, token } = req.body as PasswordResetSchema;
|
||||
|
||||
const { jwtSecret } = Config.get().security;
|
||||
|
||||
let user;
|
||||
try {
|
||||
const userTokenData = await checkToken(token, jwtSecret, true);
|
||||
const userTokenData = await checkToken(token);
|
||||
user = userTokenData.user;
|
||||
} catch {
|
||||
throw FieldErrors({
|
||||
|
||||
@@ -78,11 +78,10 @@ router.post(
|
||||
}
|
||||
}
|
||||
|
||||
const { jwtSecret } = Config.get().security;
|
||||
let user;
|
||||
|
||||
try {
|
||||
const userTokenData = await checkToken(token, jwtSecret, true);
|
||||
const userTokenData = await checkToken(token);
|
||||
user = userTokenData.user;
|
||||
} catch {
|
||||
throw FieldErrors({
|
||||
|
||||
Reference in New Issue
Block a user