2024-01-26 17:11:32 +00:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
2024-04-13 05:48:19 +00:00
|
|
|
"git.solsynth.dev/hydrogen/passport/pkg/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
|
|
|
}
|
|
|
|
}
|