getSGUserRolesForAudit returns a list of role names for the given user, if audit role filtering is enabled.
(db *db.DatabaseContext, user auth.User)
| 887 | |
| 888 | // getSGUserRolesForAudit returns a list of role names for the given user, if audit role filtering is enabled. |
| 889 | func getSGUserRolesForAudit(db *db.DatabaseContext, user auth.User) ([]string, error) { |
| 890 | if user == nil { |
| 891 | return nil, nil |
| 892 | } |
| 893 | |
| 894 | if !needRolesForAudit(db, base.UserDomainSyncGateway) { |
| 895 | return nil, nil |
| 896 | } |
| 897 | |
| 898 | roles, err := user.GetRoles() |
| 899 | if err != nil { |
| 900 | return nil, err |
| 901 | } |
| 902 | if len(roles) == 0 { |
| 903 | return nil, nil |
| 904 | } |
| 905 | |
| 906 | roleNames := make([]string, 0, len(roles)) |
| 907 | for _, role := range roles { |
| 908 | roleNames = append(roleNames, role.Name()) |
| 909 | } |
| 910 | |
| 911 | return roleNames, nil |
| 912 | } |
| 913 | |
| 914 | // checkPublicAuth verifies that the current request is authenticated for the given database. Returns an HTTPError if |
| 915 | // authentication fails. |
no test coverage detected