fix(plugins): only add app nav link if it has any pages/dashboards with role matching current user, fixes #4784

This commit is contained in:
Torkel Ödegaard
2016-04-25 14:00:49 +02:00
parent 97656d65ec
commit 04a79175bf
3 changed files with 45 additions and 10 deletions

View File

@ -1,7 +1,9 @@
package models
import (
"encoding/json"
"errors"
"fmt"
"time"
)
@ -37,6 +39,26 @@ func (r RoleType) Includes(other RoleType) bool {
return r == other
}
func (r *RoleType) UnmarshalJSON(data []byte) error {
var str string
err := json.Unmarshal(data, &str)
if err != nil {
return err
}
*r = RoleType(str)
if (*r).IsValid() == false {
if (*r) != "" {
return errors.New(fmt.Sprintf("JSON validation error: invalid role value: %s", *r))
}
*r = ROLE_VIEWER
}
return nil
}
type OrgUser struct {
Id int64
OrgId int64