Password reset & user lookup API

This commit is contained in:
2024-06-30 17:20:05 +08:00
parent e5d8f1ab3b
commit a4ccf12b7a
6 changed files with 71 additions and 41 deletions

View File

@ -14,6 +14,20 @@ import (
"github.com/spf13/viper"
)
func lookupAccount(c *fiber.Ctx) error {
probe := c.Query("probe")
if len(probe) == 0 {
return fiber.NewError(fiber.StatusBadRequest, "you must provide a probe")
}
user, err := services.LookupAccount(probe)
if err != nil {
return fiber.NewError(fiber.StatusNotFound, err.Error())
}
return c.JSON(user)
}
func getUserinfo(c *fiber.Ctx) error {
if err := exts.EnsureAuthenticated(c); err != nil {
return err

View File

@ -19,6 +19,8 @@ func MapAPIs(app *fiber.App) {
notify.Put("/:notificationId/read", markNotificationRead)
}
api.Get("/users/lookup", lookupAccount)
me := api.Group("/users/me").Name("Myself Operations")
{
@ -34,8 +36,8 @@ func MapAPIs(app *fiber.App) {
me.Delete("/tickets/:ticketId", killTicket)
me.Post("/confirm", doRegisterConfirm)
me.Post("/reset-password", requestResetPassword)
me.Patch("/reset-password", confirmResetPassword)
me.Post("/password-reset", requestResetPassword)
me.Patch("/password-reset", confirmResetPassword)
me.Get("/status", getMyselfStatus)
me.Post("/status", setStatus)