You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OneAuth/api/role/auth.go

28 lines
497 B
Go

3 years ago
package role
import (
"OneAuth/cfg"
"OneAuth/libs/auth"
3 years ago
"OneAuth/libs/base"
"OneAuth/libs/oerr"
3 years ago
"OneAuth/models"
"github.com/veypi/OneBD"
"github.com/veypi/OneBD/core"
)
var authP = OneBD.NewHandlerPool(func() core.Handler {
return &authHandler{}
})
type authHandler struct {
base.ApiHandler
}
func (h *authHandler) Get() (interface{}, error) {
if !h.GetAuth(auth.Auth).CanRead() {
return nil, oerr.NoAuth
}
3 years ago
l := make([]*models.Auth, 0, 10)
return &l, cfg.DB().Find(&l).Error
}