settings/security: generate paper key
This commit is contained in:
parent
c1daa34f2c
commit
a67c7559b9
12 changed files with 183 additions and 4 deletions
|
|
@ -4,7 +4,7 @@ use database::sqlx::SqliteExecutor;
|
|||
use database::Error as DatabaseError;
|
||||
use database::Users as DatabaseUsers;
|
||||
use email_address::EmailAddress;
|
||||
use hash::Password;
|
||||
use hash::{PaperKey, Password};
|
||||
use id::UserID;
|
||||
use std::str::FromStr;
|
||||
|
||||
|
|
@ -155,4 +155,16 @@ impl User {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn set_paper_key(
|
||||
&self,
|
||||
conn: impl SqliteExecutor<'_>,
|
||||
paper_key: Option<&PaperKey>,
|
||||
) -> Result<(), Error> {
|
||||
let paper_key = paper_key.map(|paper_key| paper_key.hash());
|
||||
|
||||
DatabaseUsers::set_paper_key(conn, self.id.as_ref(), paper_key).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue