add:module:auth:*logout | add logout module and clean all session in system
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { AppError } from "../../../helpers/error/instances/app";
|
||||
import { ErrorForwarder } from "../../../helpers/error/instances/forwarder";
|
||||
import { jwtDecode } from "../../../helpers/http/jwt/decode";
|
||||
|
||||
1
src/modules/auth/services/loginFromSystem.service.ts
Normal file
1
src/modules/auth/services/loginFromSystem.service.ts
Normal file
@ -0,0 +1 @@
|
||||
export const loginFromSystemService = (userId: string) => {};
|
||||
15
src/modules/auth/services/logout.service.ts
Normal file
15
src/modules/auth/services/logout.service.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { ErrorForwarder } from "../../../helpers/error/instances/forwarder";
|
||||
import { jwtDecode } from "../../../helpers/http/jwt/decode";
|
||||
import { deleteUserSessionInCacheAndDBService } from "../../userSession/services/deleteUserSessionInCacheAndDB.service";
|
||||
|
||||
export const logoutService = async (userCookie: string) => {
|
||||
try {
|
||||
const jwtToken = jwtDecode(userCookie);
|
||||
const deleteUserSessionInCacheAndDB =
|
||||
deleteUserSessionInCacheAndDBService(jwtToken);
|
||||
|
||||
return deleteUserSessionInCacheAndDB;
|
||||
} catch (error) {
|
||||
ErrorForwarder(error, 500, "Logout service had encountered error");
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user