2024-06-22 05:04:21 +00:00
|
|
|
package api
|
2024-01-26 17:11:32 +00:00
|
|
|
|
|
|
|
import (
|
2024-06-17 14:21:34 +00:00
|
|
|
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
|
2024-01-26 17:11:32 +00:00
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
func requestFactorToken(c *fiber.Ctx) error {
|
|
|
|
id, _ := c.ParamsInt("factorId", 0)
|
|
|
|
|
2024-04-20 11:04:33 +00:00
|
|
|
factor, err := services.GetFactor(uint(id))
|
2024-01-26 17:11:32 +00:00
|
|
|
if err != nil {
|
|
|
|
return fiber.NewError(fiber.StatusNotFound, err.Error())
|
|
|
|
}
|
|
|
|
|
2024-01-29 08:11:59 +00:00
|
|
|
if sent, err := services.GetFactorCode(factor); err != nil {
|
2024-01-26 17:11:32 +00:00
|
|
|
return fiber.NewError(fiber.StatusNotFound, err.Error())
|
2024-01-27 16:05:19 +00:00
|
|
|
} else if !sent {
|
|
|
|
return c.SendStatus(fiber.StatusNoContent)
|
|
|
|
} else {
|
|
|
|
return c.SendStatus(fiber.StatusOK)
|
2024-01-26 17:11:32 +00:00
|
|
|
}
|
|
|
|
}
|