mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 20:50:19 +08:00
Show logs to org admin
This commit is contained in:
@ -29,6 +29,11 @@ import (
|
||||
// @Success 200 {object} object.Record The Response object
|
||||
// @router /get-records [get]
|
||||
func (c *ApiController) GetRecords() {
|
||||
organization, ok := c.RequireAdmin()
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
limit := c.Input().Get("pageSize")
|
||||
page := c.Input().Get("p")
|
||||
field := c.Input().Get("field")
|
||||
@ -40,8 +45,9 @@ func (c *ApiController) GetRecords() {
|
||||
c.ServeJSON()
|
||||
} else {
|
||||
limit := util.ParseInt(limit)
|
||||
paginator := pagination.SetPaginator(c.Ctx, limit, int64(object.GetRecordCount(field, value)))
|
||||
records := object.GetPaginationRecords(paginator.Offset(), limit, field, value, sortField, sortOrder)
|
||||
filterRecord := &object.Record{Organization: organization}
|
||||
paginator := pagination.SetPaginator(c.Ctx, limit, int64(object.GetRecordCount(field, value, filterRecord)))
|
||||
records := object.GetPaginationRecords(paginator.Offset(), limit, field, value, sortField, sortOrder, filterRecord)
|
||||
c.ResponseOk(records, paginator.Nums())
|
||||
}
|
||||
}
|
||||
|
@ -90,6 +90,19 @@ func (c *ApiController) RequireSignedInUser() (*object.User, bool) {
|
||||
return user, true
|
||||
}
|
||||
|
||||
// RequireAdmin ...
|
||||
func (c *ApiController) RequireAdmin() (string, bool) {
|
||||
user, ok := c.RequireSignedInUser()
|
||||
if !ok {
|
||||
return "", false
|
||||
}
|
||||
|
||||
if user.Owner == "built-in" {
|
||||
return "", true
|
||||
}
|
||||
return user.Owner, true
|
||||
}
|
||||
|
||||
func getInitScore() (int, error) {
|
||||
return strconv.Atoi(conf.GetConfigString("initScore"))
|
||||
}
|
||||
|
Reference in New Issue
Block a user