mirror of
https://github.com/GrassrootsEconomics/cic-dw.git
synced 2024-12-22 19:07:33 +01:00
Mohamed Sohail
77f127e14a
* feat: add admin/auth api - jwt cookie based auth - /auth - admin/* * add: meta proxy * fix: remove ussd account status from syncer * add: cookie defaults and nuxt init check route * add: pin and address handlers
34 lines
694 B
Go
34 lines
694 B
Go
package admin
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
|
|
"github.com/georgysavva/scany/pgxscan"
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
type pinStatusResponse struct {
|
|
PhoneNumber string `db:"phone_number" json:"phone_number"`
|
|
FailedPinAttempts int `db:"failed_pin_attempts" json:"failed_pin_attempts"`
|
|
AccountStatus string `db:"account_status" json:"account_status"`
|
|
}
|
|
|
|
func handlePinStatus(c echo.Context) error {
|
|
var (
|
|
api = c.Get("api").(*api)
|
|
res []pinStatusResponse
|
|
)
|
|
|
|
rows, err := api.db.Query(context.Background(), api.q["pin-status"])
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := pgxscan.ScanAll(&res, rows); err != nil {
|
|
return err
|
|
}
|
|
|
|
return c.JSON(http.StatusOK, res)
|
|
}
|