Skip to content

Instantly share code, notes, and snippets.

@mikena-truss
Last active March 14, 2019 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikena-truss/da0b11bdd83e8f38fb48e104294db735 to your computer and use it in GitHub Desktop.
Save mikena-truss/da0b11bdd83e8f38fb48e104294db735 to your computer and use it in GitHub Desktop.
Example auth filter
// services/shipment/fetch_shipments.go
func newFetchShipmentsAuthorization(session Session) []Filter, err {
var filters []Filter = make([]Filter, 0)
if session.isAdmin() {
return filters, nil
} else if session.isOfficeAdmin() {
filters = append(filters, Filter{"A range filter for example..."})
return filters, nil
}
return nil, models.ErrUserUnauthorized
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment