feat: add user account verification (#2190)

* add verified column to users table

* add database functions to check if verified, or to verify

* getting there

* verification check

* use base64 urlsafe no pad

* add verification client

* clippy

* correct docs

* fix integration tests
This commit is contained in:
Ellie Huxtable
2024-06-24 14:54:54 +01:00
committed by GitHub
parent 8956142cc5
commit 67d64ec4b3
17 changed files with 401 additions and 16 deletions

View File

@ -53,6 +53,11 @@ pub trait Database: Sized + Clone + Send + Sync + 'static {
async fn get_user(&self, username: &str) -> DbResult<User>;
async fn get_user_session(&self, u: &User) -> DbResult<Session>;
async fn add_user(&self, user: &NewUser) -> DbResult<i64>;
async fn user_verified(&self, id: i64) -> DbResult<bool>;
async fn verify_user(&self, id: i64) -> DbResult<()>;
async fn user_verification_token(&self, id: i64) -> DbResult<String>;
async fn update_user_password(&self, u: &User) -> DbResult<()>;
async fn total_history(&self) -> DbResult<i64>;

View File

@ -32,6 +32,7 @@ pub struct User {
pub username: String,
pub email: String,
pub password: String,
pub verified: Option<OffsetDateTime>,
}
pub struct Session {