mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-07-03 22:45:01 +00:00
Can authenticate using security key
This commit is contained in:
@ -177,6 +177,17 @@ pub trait BaseRequestHandler {
|
||||
}
|
||||
}
|
||||
|
||||
/// Unwrap an option, returning an error if none is returned
|
||||
fn some_or_bad_request<E>(&mut self, opt: Option<E>, msg: &str) -> Res<E> {
|
||||
match opt {
|
||||
None => {
|
||||
self.bad_request(msg.to_string())?;
|
||||
unreachable!()
|
||||
}
|
||||
Some(e) => Ok(e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Get a user ID, if available
|
||||
fn user_id_opt(&self) -> Option<UserID> {
|
||||
@ -558,6 +569,13 @@ pub trait BaseRequestHandler {
|
||||
Ok(serde_json::from_str(&str)?)
|
||||
}
|
||||
|
||||
/// Get the response to a key authentication included in the request
|
||||
fn post_auth_public_key_credential(&mut self, name: &str) -> Res<webauthn_rs::proto::PublicKeyCredential> {
|
||||
let str = self.post_string(name)?;
|
||||
|
||||
Ok(serde_json::from_str(&str)?)
|
||||
}
|
||||
|
||||
/// Get the ID of a user included in a POST request
|
||||
fn post_user_id(&mut self, name: &str) -> ResultBoxError<UserID> {
|
||||
let user_id = UserID::new(self.post_u64(name)?);
|
||||
|
Reference in New Issue
Block a user