mirror of
https://github.com/KeyZox71/knl_meowscendence.git
synced 2025-10-13 18:44:45 +02:00
「✨」 feat(auth-api): /logout added
This commit is contained in:
@ -10,6 +10,7 @@ import { gRegisterCallback } from './gRegisterCallback.js';
|
||||
import { totpSetup } from './totpSetup.js';
|
||||
import { totpDelete } from './totpDelete.js';
|
||||
import { totpVerify } from './totpVerify.js';
|
||||
import { logout } from './logout.js';
|
||||
|
||||
const saltRounds = 10;
|
||||
export const appName = process.env.APP_NAME || 'knl_meowscendence';
|
||||
@ -107,4 +108,6 @@ export default async function(fastify, options) {
|
||||
}
|
||||
}
|
||||
}, async (request, reply) => { return register(request, reply, saltRounds, fastify); });
|
||||
|
||||
fastify.get('/logout', {}, async (request, reply) => { return logout(request, reply, fastify); })
|
||||
}
|
||||
|
17
src/api/auth/logout.js
Normal file
17
src/api/auth/logout.js
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @async
|
||||
* @param {import("fastify").FastifyReply} reply
|
||||
*
|
||||
* @returns {import("fastify").FastifyReply}
|
||||
*/
|
||||
export async function logout(reply) {
|
||||
try {
|
||||
return reply
|
||||
.code(200)
|
||||
.clearCookie()
|
||||
.send({ msg: "Logout successful" });
|
||||
} catch {
|
||||
fastify.log.error(err);
|
||||
return reply.code(500).send({ error: "Internal server error" });
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user