📝」 doc(auth): added doc for 2fa in login

This commit is contained in:
2025-10-16 12:33:49 +02:00
parent f689274716
commit 95cbbc6613
2 changed files with 11 additions and 4 deletions

View File

@ -21,7 +21,8 @@ Input needed :
```json
{
"user": "<string>",
"password": "<string>"
"password": "<string>",
(optional)"token": "<2fa token>"
}
```
@ -32,7 +33,13 @@ Can return:
"msg": "Login successfully"
}
```
- 400 with response
- 402 with response
```json
{
"msg": "Please specify a 2fa token"
}
```
- 400 || 401 with response
```json
{
"error": "<corresponding error>"

View File

@ -37,8 +37,8 @@ export async function login(request, reply, fastify) {
const userTOTP = authDB.getUser(user);
if (userTOTP.totpEnabled == 1) {
if (!request.body.token){
return reply.code(401).send({ error: 'Invalid 2FA token' });
if (!request.body.token) {
return reply.code(402).send({ error: 'Please specify a 2fa token' });
}
const isValid = verifyTOTP(userTOTP.totpHash, request.body.token);
if (!isValid) {