totp: generate backup code, attempt to use backup code when checking totp, delete backup after successful use
This commit is contained in:
parent
830f1dc0ae
commit
da4b204601
8 changed files with 169 additions and 18 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use crate::error::Error;
|
||||
use crate::hash::{hash, Hash};
|
||||
use nanoid::nanoid;
|
||||
use nanoid_dictionary::ALPHANUMERIC;
|
||||
use nanoid_dictionary::{ALPHANUMERIC, NUMBERS};
|
||||
use std::fmt::{Display, Formatter};
|
||||
|
||||
// Struct to generate the secret
|
||||
|
|
@ -10,6 +10,9 @@ impl SecretString {
|
|||
pub fn new(length: usize) -> Self {
|
||||
Self(nanoid!(length, ALPHANUMERIC))
|
||||
}
|
||||
pub fn new_digits(length: usize) -> Self {
|
||||
Self(nanoid!(length, NUMBERS))
|
||||
}
|
||||
}
|
||||
impl Default for SecretString {
|
||||
fn default() -> Self {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue