mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-20 20:59:16 +00:00
chore: removed redundant user check on session controller
This commit is contained in:
@@ -30,10 +30,6 @@ export const RefreshTokenService = async (token: string): Promise<Response> => {
|
|||||||
|
|
||||||
const user = await ShowUserService(id);
|
const user = await ShowUserService(id);
|
||||||
|
|
||||||
if (!user) {
|
|
||||||
throw new AppError("No user found with this ID.", 401);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user.tokenVersion !== tokenVersion) {
|
if (user.tokenVersion !== tokenVersion) {
|
||||||
throw new AppError("Session revoked. Please login.", 401);
|
throw new AppError("Session revoked. Please login.", 401);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import User from "../../models/User";
|
import User from "../../models/User";
|
||||||
import AppError from "../../errors/AppError";
|
import AppError from "../../errors/AppError";
|
||||||
|
|
||||||
const ShowUserService = async (
|
const ShowUserService = async (id: string | number): Promise<User> => {
|
||||||
id: string | number
|
|
||||||
): Promise<User | undefined> => {
|
|
||||||
const user = await User.findByPk(id, {
|
const user = await User.findByPk(id, {
|
||||||
attributes: ["name", "id", "email", "profile", "tokenVersion"]
|
attributes: ["name", "id", "email", "profile", "tokenVersion"]
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user