cic-dw/internal/admin/pins.go
Mohamed Sohail 77f127e14a
feat: add admin/auth api (#22)
* 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
2022-06-02 11:24:58 +03:00

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)
}