mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 12:37:00 +01:00
chore: Remove empty scopemaps (#3170)
This commit is contained in:
parent
7a9bb9eac2
commit
f68906bf1b
|
@ -200,6 +200,7 @@ pub(crate) async fn oauth2_id_scopemap_post(
|
||||||
Json(scopes): Json<Vec<String>>,
|
Json(scopes): Json<Vec<String>>,
|
||||||
) -> Result<Json<()>, WebError> {
|
) -> Result<Json<()>, WebError> {
|
||||||
let filter = oauth2_id(&rs_name);
|
let filter = oauth2_id(&rs_name);
|
||||||
|
|
||||||
state
|
state
|
||||||
.qe_w_ref
|
.qe_w_ref
|
||||||
.handle_oauth2_scopemap_update(client_auth_info, group, scopes, filter, kopid.eventid)
|
.handle_oauth2_scopemap_update(client_auth_info, group, scopes, filter, kopid.eventid)
|
||||||
|
|
|
@ -279,6 +279,7 @@ impl ValueSetT for ValueSetOauthScopeMap {
|
||||||
match value {
|
match value {
|
||||||
Value::OauthScopeMap(u, m) => {
|
Value::OauthScopeMap(u, m) => {
|
||||||
match self.map.entry(u) {
|
match self.map.entry(u) {
|
||||||
|
// We are going to assume that a vacant entry will not be set to empty.
|
||||||
BTreeEntry::Vacant(e) => {
|
BTreeEntry::Vacant(e) => {
|
||||||
e.insert(m);
|
e.insert(m);
|
||||||
Ok(true)
|
Ok(true)
|
||||||
|
@ -289,7 +290,12 @@ impl ValueSetT for ValueSetOauthScopeMap {
|
||||||
// associated map state. So by always replacing on a present, we are true to
|
// associated map state. So by always replacing on a present, we are true to
|
||||||
// the intent of the api.
|
// the intent of the api.
|
||||||
BTreeEntry::Occupied(mut e) => {
|
BTreeEntry::Occupied(mut e) => {
|
||||||
e.insert(m);
|
if m.is_empty() {
|
||||||
|
e.remove();
|
||||||
|
} else {
|
||||||
|
e.insert(m);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue