1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-20 08:25:16 +00:00

Can remove a key from the list of keys of an admin

This commit is contained in:
2021-05-14 15:08:39 +02:00
parent 22b3a73db3
commit 5abd4979a3
3 changed files with 28 additions and 0 deletions

View File

@ -153,6 +153,26 @@ pub fn register_key(r: &mut HttpRequestHandler) -> RequestResult {
r.ok()
}
/// Delete an admin auth key
pub fn delete_auth_key(r: &mut HttpRequestHandler) -> RequestResult {
let admin_id = r.post_admin_id("adminID")?;
let key_id = r.post_u64("keyID")?;
if admin_id != r.admin_id()? {
unimplemented!(); // TODO
}
for key in admin_account_key_helper::get_admin_keys(admin_id)? {
if key.id == key_id {
admin_account_key_helper::delete_key(key)?;
return r.ok();
}
}
r.not_found("Requested key was not found!".to_string())
}
/// Generate a challenge to authenticate with a security key
pub fn challenge_auth_with_key(r: &mut HttpRequestHandler) -> RequestResult {
let key = r.post_admin_auth_key("mail", "key_id")?;