✨ feat: add logout feature
All checks were successful
Integration Tests / integration-tests (pull_request) Successful in 1m44s
All checks were successful
Integration Tests / integration-tests (pull_request) Successful in 1m44s
This commit is contained in:
23
shared/models/auth/logout.ts
Normal file
23
shared/models/auth/logout.ts
Normal file
@ -0,0 +1,23 @@
|
||||
"use server";
|
||||
|
||||
import { backendFetch } from "@/shared/helpers/backendFetch";
|
||||
import { cookies } from "next/headers";
|
||||
|
||||
export const logout = async () => {
|
||||
const res = await backendFetch("auth/logout", {
|
||||
method: "POST",
|
||||
});
|
||||
|
||||
if (res.success) {
|
||||
(await cookies()).delete("auth_token");
|
||||
return {
|
||||
success: true,
|
||||
message: "Logged out successfully",
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
success: false,
|
||||
message: "Logout failed",
|
||||
};
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user