Browse Source

if empty use email instead of name for webauhn

pull/6733/head
stefan0xC 7 days ago
parent
commit
63f47df942
No known key found for this signature in database GPG Key ID: 817020C608FE9C09
  1. 2
      src/api/core/two_factor/webauthn.rs
  2. 9
      src/db/models/user.rs

2
src/api/core/two_factor/webauthn.rs

@ -144,7 +144,7 @@ async fn generate_webauthn_challenge(data: Json<PasswordOrOtpData>, headers: Hea
let (mut challenge, state) = WEBAUTHN.start_passkey_registration(
Uuid::from_str(&user.uuid).expect("Failed to parse UUID"), // Should never fail
&user.email,
&user.name,
user.display_name(),
Some(registrations),
)?;

9
src/db/models/user.rs

@ -231,6 +231,15 @@ impl User {
pub fn reset_stamp_exception(&mut self) {
self.stamp_exception = None;
}
pub fn display_name(&self) -> &str {
// default to email if name is empty
if !&self.name.is_empty() {
&self.name
} else {
&self.email
}
}
}
/// Database methods

Loading…
Cancel
Save