🚚 create backup folder
create backup folder for archive the old modules
This commit is contained in:
@ -0,0 +1,24 @@
|
||||
import { ErrorForwarder } from "../../../helpers/error/instances/forwarder";
|
||||
import { findUniqueUserSessionInDBRepo } from "../repositories/findUniqueUserSessionInDB.repository";
|
||||
|
||||
export const getUserSessionFromDBService = async (identifier: string) => {
|
||||
try {
|
||||
// Check is session exists in DB
|
||||
const userSession = await findUniqueUserSessionInDBRepo(identifier);
|
||||
|
||||
// If session not found, return false
|
||||
if (
|
||||
!userSession ||
|
||||
!userSession.isAuthenticated ||
|
||||
userSession.deletedAt ||
|
||||
new Date(userSession.validUntil) < new Date()
|
||||
)
|
||||
return false;
|
||||
|
||||
// If session found, return it
|
||||
return userSession;
|
||||
} catch (error) {
|
||||
// If any DB error occurs, throw an AppError
|
||||
ErrorForwarder(error, 401, "Unable to get user session");
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user