UpdateModelAllowlist updates the model allowlist for a user.
(db *gorm.DB, userID string, allowlist ModelAllowlist)
| 201 | |
| 202 | // UpdateModelAllowlist updates the model allowlist for a user. |
| 203 | func UpdateModelAllowlist(db *gorm.DB, userID string, allowlist ModelAllowlist) error { |
| 204 | perm, err := GetUserPermissions(db, userID) |
| 205 | if err != nil { |
| 206 | return err |
| 207 | } |
| 208 | perm.AllowedModels = allowlist |
| 209 | return db.Save(perm).Error |
| 210 | } |
| 211 | |
| 212 | // IsModelAllowed returns true if the user is allowed to use the given model. |
| 213 | // Admins always have access. If the allowlist is not enabled, all models are allowed. |
no test coverage detected